Python is faster than C

Joe Mason joe at notcharles.ca
Sun Apr 4 00:22:14 EST 2004


In article <406F5E95.EBE6D3E8 at tunes.org>, Armin Rigo wrote:
> Another example would be 'a'*999999999: the result is a string, but
> there is no reason that it takes 100MB of memory.  Instead, store it
> into a C structure that contains a pointer to the original string object
> 'a' and the repetition counter, but still give this C structure the
> Python type str, so that the difference doesn't show up and the Python
> language remains simple.  (This is a bit difficult to implement
> currently in CPython, but not impossible.)

What this does is makes the interpreter more complicated for features
that not all programs will use.  Only a very few programs will have long
strings of repeated characters, and it's reasonable to ask them to
implement their own stringlike class if they really want it.  

If this is built into the interpreter, then either it's an optional
feature, in which case all those programs that rely on it to be remotely
memory-efficient aren't portable, or it requires every single
implementation to include it, including the PalmOS port and the one
that's supposed to run on cell phones.

Joe



More information about the Python-list mailing list