[issue6684] "x / 1" and "x * 1" should return x
mrjbq7
report at bugs.python.org
Tue Aug 11 18:44:30 CEST 2009
New submission from mrjbq7 <mrjbq7 at users.sourceforge.net>:
There are a couple arithmetic operations that idempotent, where the
returned python object is the same python object as the input.
For example, given a number:
>>> x = 12345
The abs() builtin returns the same number object if it is already a
positive value:
>>> id(x)
17124964
>>> id(abs(x))
17124964
The "multiply by zero" operation returns a single "zero" object:
>>> id(x * 0)
16794004
>>> id(x * 0)
16794004
But, the "multiply by 1" or "divide by 1" does not:
>>> id(x * 1)
17124928
>>> id(x * 1)
17124880
>>> id(x / 1)
17203652
>>> id(x / 1)
17124952
----------
messages: 91479
nosy: mrjbq7
severity: normal
status: open
title: "x / 1" and "x * 1" should return x
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6684>
_______________________________________
More information about the Python-bugs-list
mailing list