From: "William D. Neumann" <wneumann@cs.unm.edu>
To: Jon Harrop <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Correct way of programming a CGI script
Date: Tue, 9 Oct 2007 10:18:49 -0500 [thread overview]
Message-ID: <20071009151808.M4217@cs.unm.edu> (raw)
In-Reply-To: <200710091456.37798.jon@ffconsultancy.com>
On Tue, 9 Oct 2007 14:56:37 +0100, Jon Harrop wrote
> In this context, yes. In general, strings are not as efficient as
> the equivalent concrete data structure in C. Specifically, using
> strings as a byte array and applying arithmetic operations to the
> elements is significantly slower in OCaml than C.
>
> The only option you have in OCaml is to blow your memory wad and use
> an int array, which is fast but wastes enormous amounts of space and
> still has different modulo-arithmetic properties (you might want 8-
> bit for some apps). Consequently, OCaml is not very good for
> arithmetic operations over byte arrays.
I'd moaned about this a few years ago, and Xavier pointed out the following:
"A better alternative is to declare
external get_byte: string -> int -> int = "%string_safe_get"
external set_byte: string -> int -> int -> unit = "%string_safe_set"
and use these two functions to access strings as if they were byte
arrays. set_byte will store the low 8 bits of its third argument, so
you'd save on "land 0xFF" operations too."
It works pretty well for getting and setting bytes of a string. There's
also the int8_* bigarrays, but I've not used them much, so I can't say if
they're of much help, but they certainly weren't horrible.
--
William D. Neumann
next prev parent reply other threads:[~2007-10-09 15:18 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-08 15:08 Tom
2007-10-08 15:32 ` [Caml-list] " Dario Teixeira
2007-10-08 16:04 ` Gerd Stolpmann
2007-10-08 21:37 ` skaller
2007-10-08 22:21 ` Erik de Castro Lopo
2007-10-08 23:05 ` skaller
2007-10-08 23:19 ` skaller
2007-10-08 23:23 ` Arnaud Spiwack
2007-10-08 23:47 ` skaller
2007-10-09 5:49 ` David Teller
2007-10-09 10:15 ` Christophe TROESTLER
2007-10-09 15:29 ` skaller
2007-10-09 15:49 ` Vincent Hanquez
2007-10-09 16:00 ` Jon Harrop
2007-10-09 14:02 ` William D. Neumann
2007-10-09 15:25 ` skaller
2007-10-09 15:33 ` William D. Neumann
2007-10-09 15:48 ` Jon Harrop
2007-10-08 23:37 ` skaller
2007-10-09 10:20 ` Christophe TROESTLER
2007-10-09 13:40 ` Rope is the new string Jon Harrop
2007-10-09 15:57 ` [Caml-list] " Vincent Hanquez
2007-10-09 16:42 ` Loup Vaillant
2007-10-09 16:55 ` Vincent Hanquez
2007-10-09 17:32 ` Loup Vaillant
2007-10-09 19:51 ` Vincent Hanquez
2007-10-09 21:06 ` Loup Vaillant
2007-10-10 7:35 ` Vincent Hanquez
2007-10-10 8:05 ` Loup Vaillant
2007-10-11 13:23 ` Vincent Hanquez
2007-10-09 22:04 ` Chris King
2007-10-11 13:03 ` Vincent Hanquez
2007-10-11 13:54 ` skaller
2007-10-11 14:21 ` Vincent Hanquez
2007-10-11 14:27 ` Benjamin Monate
2007-10-11 14:48 ` skaller
2007-10-11 21:16 ` Alain Frisch
2007-10-15 20:35 ` Warning on home-made functions dealing with UTF-8 Julien Moutinho
2007-10-15 23:51 ` [Caml-list] " skaller
2007-10-16 2:21 ` Julien Moutinho
2007-10-16 18:46 ` Julien Moutinho
2007-10-16 18:51 ` Julien Moutinho
2007-10-17 2:23 ` [Caml-list] " skaller
2007-10-09 10:26 ` [Caml-list] Correct way of programming a CGI script Gerd Stolpmann
2007-10-09 15:16 ` skaller
2007-10-09 15:31 ` William D. Neumann
2007-10-09 12:52 ` Brian Hurt
2007-10-09 13:56 ` Jon Harrop
2007-10-09 15:18 ` William D. Neumann [this message]
2007-10-08 16:11 ` Loup Vaillant
2007-10-08 19:07 ` Christophe TROESTLER
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071009151808.M4217@cs.unm.edu \
--to=wneumann@cs.unm.edu \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox