Hey Andreas, I'd be happy to use the future version and switch the uses of "/" to "//" when floordiv was intended. It should be pretty obvious when floordiv was intended, and I imagine that it's every case of "/" in the current codebase.
I *do* hope that Python 3 returns 1.5 for 3/2 and not 1.4, though. ;) Cheers, Jason On Mon, Feb 25, 2019 at 6:41 AM Andreas Sandberg <[email protected]> wrote: > 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 _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev
