Why Is Escaping Data Considered So Magical?

Paul Rubin no.email at nospam.invalid
Mon Jun 28 05:48:34 EDT 2010


Gregory Ewing <greg.ewing at canterbury.ac.nz> writes:
> I don't think it was as stupid as that back when C was
> designed. Every byte of memory was precious in those days,
> and if you had, say, 10 bytes allocated for a string, you
> wanted to be able to use all 10 of them for useful data.

No I don't think so.  Traditional C strings simply didn't carry length
info except for the nul byte at the end.  Most string functions expected
the nul to be there.  The nul byte convention (instead of having a
header word with a length) arguably saved some space both by eliminating
a multi-byte header and by allowing trailing substrings to be
represented as pointers into a larger string.  In retrospect it seems
like a big error.



More information about the Python-list mailing list