Reputation: 13
I know python has inbuilt string support. But what I would like to know is how it handles the end of string construct. C has '\0' character to signify end of string. How does python do it? It would be great if someone could tell me how it works in the cpython source code.
Upvotes: 1
Views: 1447
Reputation: 60207
AFAIK, CPython keeps track of the length and start of the string. As of CPython 3.3 it also keeps track of how many bytes per character in order to compress strings that can fit into subsets of the Unicode spectrum, such as Latin-1 strings.
Upvotes: 1