[Python-Dev] Wild Idea for the Year
Guido van Rossum
guido at python.org
Thu Jun 24 10:36:29 EDT 2004
> > But wait, I think it won't fly at all unless you make ob_sval a
> > pointer to separately allocated memory. Otherwise, how could
> > _autojoin() possibly "fix" the string without allocating the memory
> > for it?
>
> PyString_Resize().
This moves the string in memory, and therefore only works when there
is exactly one reference to the object (the one you pass in).
Otherwise you'd have to find and patch up all references to the
object.
> BTW, there is a proof-of-concept demo patch with UserString at:
> www.python.org/sf/976162
That's using a Python class, which doesn't have the resizing problem
because it is implemented using a reference to the actual string data.
> Also, there is an alternative approach of having str.__add__() return a
> string proxy. This would avoid issues with 3rd party code.
>
> That being said, I didn't miss that you hate the idea, so I'll craft a
> recipe and drop it :-(
Hate is too strong, but I think it is unnecessary encroachment. I
worry about Python losing its KISS principle. Python 2.2 has been
ported to the Nokia Series 60 platform, which has something like 8-16
MB of RAM available. I'm sure the footprint growth of Python 2.3 and
2.4 gives those developers nightmares already when they are thinking
of tracking later versions...
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list