Future division patch available (PEP 238)

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Jul 23 04:33:08 EDT 2001


Stephen Horne <steve at lurking.demon.co.uk> writes:

> Division on integers should be integer division. 

I don't think there is any argument about that: the only question is
how to spell integer division; in the future, it will be spelled '//'.

> Mathematically, integer division should be the inverse of integer
> multiplication, with no extra functionality bar the need to allow for
> the remainder. Well shock horror - that's exactly what we've got now
> and exactly what we're throwing away.

We are not - we are just spelling it differently. However, if you
think that the inverse of multiplication on integers should be spelled
'/' (even though the integers do not form a group with respect to
multiplication), you could still get this under the new PEP. It would
be possible to implement

12/4 is 3 (not 3.0)
14/4 == 3.5

> Integer division is important to a huge range of applications -
> anything involving money stands out as the obvious case, but also
> cryptography and others.

Indeed, integer division will not go away.

Regards,
Martin



More information about the Python-list mailing list