← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1194497] Re: xrange incompatible with py3. range bad in py2.

 

patch abandoned.

** Changed in: nova
       Status: In Progress => Opinion

** Changed in: nova
     Assignee: Kevin Conway (kevinconway) => (unassigned)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1194497

Title:
  xrange incompatible with py3. range bad in py2.

Status in OpenStack Compute (Nova):
  Opinion

Bug description:
  The nova code has a mixed usage of `range` and `xrange`.

  The `xrange` usage is preferred on py2 environments because it makes
  use of a generator rather than attempting to construct an entire list
  in memory. In py3, however, the `xrange` built-in no longer exists
  because it has been renamed `range`.

  This could cause several problems. The use of `range` in py2 for any
  significant size input will have a noticeable impact on performance.
  The use of `xrange` in py3 will cause a `NameError`.

  This is a case where the most appropriate solution is to break from
  the HACKING.rst guidelines and shadow a built-in and make `range` and
  alias for `xrange` in py2 environments. This would allow us to
  normalize the usage of `range` vs `xrange` as well as ensure that all
  calls to `range` are using the version with the best performance.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1194497/+subscriptions