optimization question

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Tue Aug 13 07:40:58 CEST 2002

Skip Montanaro <skip at pobox.com> writes:
> In theory, I suppose that's true.  However, note that performance of such a
> modified Python interpreter would probably suffer, because any time the
> interpreter wanted to call a C routine which expected a null-terminated
> string (e.g. strchr), it would have to be copied first (or at least
> inspected using the stored length), since any string's (and b's in
> particular) internal representation wouldn't necessarily be null-terminated.
> CPython's current implementation always null-terminates strings to avoid
> copying.

But Python strings can have nulls in them, so if you use functions like
strchr on them, you can get the wrong answer.

More information about the Python-list mailing list