Third Draft: Pep for Deprecating Builtins

Alex Martelli aleax at aleax.it
Tue Apr 30 04:32:34 EDT 2002


Arthur Siegel wrote:

>>I'm not convinced Python 3 is a "new enough" language for this PEP's
>>ideas, although that would seem the obvious point for this sort of
>>tinkering
> 
> Perhaps I don't understand the transition path to new style classes.
> 
> Is the plan to have the 2 class structures co-exist indefinitely?
> That would seem strange and more than a little ugly.
> 
> But isn't the concept of deprecating old style classes near
> impossible, as a real world matter?

Why would it be?  The degree of compatibility between new-style classes and 
classic ones is amazing.  Try sticking a __metaclass__=type at the top of
your modules and see what little breaks -- basically only some rather 
obscure and advanced metaprogramming techniques, hardly make-or-break issues
for "real world matters".

I'm not into channeling GvR (you need the timbot for that), so I can't claim
I know what is The Plan, but a slow and gradual transition to "exclusive" 
use of new-style classes over a few releases seems perfectly feasible to 
me, given the high degree of compatibility GvR was able to achieve.

The quotes around "exclusive" are due to my doubts about your assertion
above, which translates into "having more than one kind of metaclass 
available seems strange and more than a little ugly".  Why couldn't
Python supply two or more metaclasses ready for use, just as it offers
both type and types.ClassType today?  I.e., why should all metaclasses
other than the built-in type be necessarily user-coded ones, or third
party extensions -- certainly there IS space for some in Python's large
standard library, no?

So, types.ClassType COULD stay around "forever" from my POV, even long after
the default metaclass has become type -- at worst, the way to enable the
alternative metaclass as the default one would be 2 lines at module scope:

import types
__metaclass__ = types.ClassType

If some few percents of code need this peculiar metaclass, or others yet,
why couldn't they conceptually be supplied in such wise...?


Alex




More information about the Python-list mailing list