[Python-Dev] String views (was: Re: Proof of the pudding:str.partition())

skip@pobox.com skip at pobox.com
Fri Sep 2 04:57:29 CEST 2005

    Fredrik> Python strings are character buffers with a known length, not
    Fredrik> null-terminated C strings.  the CPython implementation
    Fredrik> guarantees that the character buffer has a trailing NULL
    Fredrik> character, but that's mostly to make it easy to pass Python
    Fredrik> strings directly to traditional C API:s.

I'm obviously missing something that's been there all along.  Since Python
strings can contain NULs, why do we bother to NUL-terminate them?  Clearly,
any tradition C API that expects to operate on NUL-terminated strings would
break with a string containing an embedded NUL.


More information about the Python-Dev mailing list