[Python-Dev] String views (was: Re: Proof of the pudding:str.partition())
Fredrik Lundh
fredrik at pythonware.com
Thu Sep 1 08:40:19 CEST 2005
More information about the Python-Dev mailing list
Thu Sep 1 08:40:19 CEST 2005
- Previous message: [Python-Dev] String views
- Next message: [Python-Dev] String views (was: Re: Proof of the pudding:str.partition())
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
skip at pobox.com wrote: > As a Python programmer I'd get back what look like three strings: "http", > ":", and "//www.python.org/". If each of them was a view onto part of the > original string, only the last one would truly refer to a NUL-terminated > sequence of characters. If I then wanted to see what scheme's value > compared to, the string's comparison method would have to recognize that > it > wasn't truly NUL-terminated, copy it, call strncmp() or whatever > underlying > routine is used for string comparisons. (Maybe string comparisons are > done > inline. I'm sure there are some examples where the underlying C string > routines are called.) Python strings are character buffers with a known length, not null-terminated C strings. the CPython implementation guarantees that the character buffer has a trailing NULL character, but that's mostly to make it easy to pass Python strings directly to traditional C API:s. (string views are nothing new in Python. the original Unicode string implementation supported this, but that was partially removed during integration. the type still uses a separate buffer to hold the characters, though (unlike 8-bit strings that store the characters in the string object itself)) </F>
- Previous message: [Python-Dev] String views
- Next message: [Python-Dev] String views (was: Re: Proof of the pudding:str.partition())
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list