Should I change the name of __new__? (Re: [Pyrex] Inheritance for extension types)

Greg Ewing greg at cosc.canterbury.ac.nz
Fri Feb 13 01:21:56 CET 2004


Konrad Hinsen <hinsen at cnrs-orleans.fr>:

> I guess the reason is that you are calling a superclass method within
> __new__.  When the method __new__ is called, the object is not yet in
> a consistent internal state, which means that some operations are not
> allowed.

What's probably happening is that A.__new__ is returning
a method, but not one that does what you think it's going
to do. Pyrex's __new__ method is actually something quite
different from Python's __new__, and calling it __new__
was probably a mistake.

I've been thinking about changing its name to something
else, both to help avoid leading people into this sort
of trap, and also to clear the way for possibly implementing
a true Python-style __new__ for extension types at some
time in the future.

However, this will break a large proportion of Pyrex code
people have already written, so I may need to phase it in
by allowing __new__ as a synonym for a while, with a warning
that its semantics may change.

How do people feel about this?

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list