[Numpy-discussion] Changing the behavior of (builtins.)round (via the __round__ dunder) to return an integer

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Apr 13 11:06:43 EDT 2016

On Wed, Apr 13, 2016 at 4:31 AM, Stephan Hoyer <shoyer at gmail.com> wrote:

> On Wed, Apr 13, 2016 at 12:42 AM, Antony Lee <antony.lee at berkeley.edu>
> wrote:
>> (Note that I am suggesting to switch to the new behavior regardless of
>> the version of Python.)
> I would lean towards making this change only for Python 3. This is
> arguably more consistent with Python than changing the behavior on Python
> 2.7, too.
> The most obvious way in which a float being surprisingly switched to an
> integer could cause silent bugs (rather than noisy TypeErrors) is if the
> number is used in division. True division in Python 3 eliminates this risk.
> Generally, I agree with your reasoning. It would be unfortunate to be
> stuck with this legacy behavior forever.
The difference is that Python 3 has looooong ints, (and doesn't have to
overflow, AFAICS)

what happens with nan?
I guess inf would overflow?

(nan and inf are preserved with np.round)


> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160413/bb8f93b1/attachment.html>

More information about the NumPy-Discussion mailing list