[Python-Dev] 'new' and 'types'

Oren Tirosh oren-py-d@hishome.net
Fri, 14 Jun 2002 19:15:58 +0300


Patch 568629 removes the built-in module new (with sincere apologies to 
Tommy Burnette ;-) and replaces it with a tiny Python module consisting of a 
single import statement:

"""This module is no longer required except for backward compatibility.
Objects of most types can now be created by calling the type object. """

from types import \
ClassType as classobj, \
CodeType as code, \
FunctionType as function, \
InstanceType as instance, \
MethodType as instancemethod, \
ModuleType as module

These types (as well as buffer and slice) have been made callable. It looks 
like the Python core no longer has any objects that are created by a 
separate factory function (there are still some in the Modules).

Now, what about the types module?  It has been suggested that this module
should be deprecated.  I think it still has some use: we need a place to put
all the types that are not used often enough to be added to the builtins.
I suggest that they be placed in the module 'types' with names matching their
__name__ attribute.  The types module will still have the long MixedCaseType 
names for backward compatibility.  The use of the long names should be 
deprecated, not the types module itself.

    Oren