Gregory Ewing <greg.ew...@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. -- http://mail.python.org/mailman/listinfo/python-list