[Python-Dev] Work in progress - coercion/cmp overhaul
Wed, 15 Nov 2000 09:35:59 -0800
[The python-dev list server seems to have gotten hungry and eaten my
original message. I'm trying again.]
I making this available now in the hope that it will generate
The patch is based on Marc-Andre Lemburg's coercion patch for
1.5.1 downloaded from the starship:
All credit goes to him. The bugs are probably introduced by me.
What the patch does:
- Introduces a new type flag "NEWSYTLENUMBER". If this flag is
set then the tp_as_number methods are treated differently.
Coercion is not done before passing arguments to the method.
New style methods do their own coercion or return the
NotImplemented singleton. See Marc's page for more details.
- Updates the PyInt, PyFloat and PyInstance types to use new
- Changes PyNumber_Multiply to only swap arguments if second
argument implements sq_repeat.
- It gives extension types more control over how they implement
- Removes the special handling of PyInstance in abstract.c.
- Slightly speeds up the interpreter.
- Clean up cmp() operator and implement rich comparsions for
the new nb_cmp slot.
- Decide on handling of nb_coerce slot (eg. should it be called
on new style numbers).
- Convert PyComplex and PyLong to use new style.