Comment on PEP-0238

Guido van Rossum guido at python.org
Wed Jul 11 10:26:41 EDT 2001


Greg Ewing <greg at cosc.canterbury.ac.nz> writes:

> Guido van Rossum wrote:
> > 
> > I just discovered that we don't need to add a new operator overloading
> > name for the div and mod operations: classes already look for a
> > __divmod__ method to overload divmod(), and we should naturally define
> > div(x, y) (or x div y) as divmod(x, y)[0].
> 
> That sounds suspiciously similar to the argument that
> we don't need __eq__, __le__ etc. because we can just
> as well funnel them all through __cmp__...

Darn.  That's a reasonable argument.  If a numeric array module
defines __divmod__, does it return a tuple of two arrays, or does it
return an array of tuples?  In either case, it would be a waste for
div to call __divmod__ and then have to throw away half of the
result.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list