[issue5211] Fix complex type to avoid coercion in 2.7.
report at bugs.python.org
Sun Nov 28 21:46:21 CET 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
> Just to keep this discussion as clear as possible Mark, it was your
> first option that I suggest is needed.
Okay, so you want <float instance> + <xint instance> to try xint.__radd__ before float.__add__.
How do you propose this be achieved? Can you explain exactly what semantics you'd like to see? You've indicated what you want to happen for float and xint, but how should Python behave in general here?
In particular, when evaluating 'x + y' for general Python objects x and y, what rule or rules should Python use to decide whether to try x.__add__(y) or y.__radd__(x) first?
It seems you want some general mechanism that results in xint being 'preferred' to float, in the sense that xint.__radd__ and xint.__add__ will be tried in preference to float.__add__ and float.__radd__ (respectively). But it's not clear to me what criterion Python would use to determine which out of two types (neither one inheriting from the other) should be 'preferred' in this sense.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list