Hi Everyone,

TL;DR; Python 3 changes the default behaviour of division. Should we
enable the same behaviour in Python 2.7?

Most of you have probably been hit by my Python 3 spam recently. Sorry
about that. :( The good news is that there are only a handful of changes
left to merge before gem5 works in Python 3. Once that happens, we'll
probably start running (some of) our internal regressions using Python 3
instead of (or in addition to) Python 2.7.

There is still one potential gotcha when using Python 3 in gem5, integer
divisions. Unlike Python 2.7, the default behaviour when dividing two
integers in Python 3 is to promote to floating point if necessary. I.e.,
if you were to evaluate 3/2 in you'd get the following results:

Python 3: 1.4
Python 2.x: 1

The operator above is known as "true division" (__truediv__) in Python
3. To get the old behaviour, there is a new operator (// or
__floordiv__) called floor division that is supported since Python 2.2.
For example, evaluating 3//2 would result in 1 in both Python 2.7 and
Python 3.

The new behaviour can be enabled by default in Python 2.7 by importing
division from __future__. Should we enable this by default to get
consistent behaviour of division across Python 2 and 3?

Cheers,
Andreas


IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to