New submission from mrjbq7 <mrj...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue6684>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to