PEP0238: overriding // (__intdiv__) ??
robin at jessikat.fsnet.co.uk
Wed Jul 25 08:34:33 EDT 2001
In article <snatltotvlevdqc7kaj1m8v82o5fv51543 at 4ax.com>, Kirby Urner
<urner at alumni.princeton.edu> writes
>Maybe I missed it. Did the PEP specify what we'd use
>to override the // operator in a class? __intdiv__ and
>__rintdiv__ ? Seems we'd need something like this, to
>have our objects play along. And I'd think this wrinkle
>should become available simultaneously with //.
If and when the grand type class unification takes place and ints,
longs, floats rationals and the like are all properly sub-classable,
will it possible to inject behaviours into those types? If so then I can
trivially change '/' by changing the base implementations for the
I suppose that there are efficiency arguments involved, but the compiler
must issue a divide instruction anyhow and leave it up to the operand
classes to decide what to do.
That way we could begin to treat this as a properly abstract programming
language. It could of course lead to utter confusion.
More information about the Python-list