[Python-3000] PyUnicodeObject implementation

Guido van Rossum guido at python.org
Sun Sep 7 16:38:06 CEST 2008


On Sun, Sep 7, 2008 at 12:15 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Antoine Pitrou wrote:
>> Also note that Marc-André Lemburg (one of the authors of the unicode
>> implementation) is opposed to that change. See the discussion in the bug tracker
>> issue for the details.
>
> From a Cython perspective, I find the lack of efficient subclassing after such
> a change particularly striking. That seriously bit me in Py2 when I tried
> making XML text content a bit more intelligent in lxml (i.e. make it remember
> what XML element it originated from). Having the same problem for unicode in
> Py3 doesn't sound like a good idea to me.

Can you explain this a bit more? I presume you're talking about
subclassing in C, which always precarious -- from the Python
perspective there's no difference, the objects are opaque. I do note
that the mechanisms that exist for supporting adding a __dict__ to a
str (in 2.x; or bytes in 3.x) or a tuple could be extended for other
purposes.

Also, please explain why instead of subclassing you couldn't use a
wrapper class? (I.e. use containment instead of inheritance.)

All in all, given the advantage (half the number of allocations) of
the proposal I think there would have to be *very* good arguments
against before we reject this outright. I'd like to understand
Marc-Andre's reasons too.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list