Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 compatibility improved #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Python 3 compatibility improved #6

wants to merge 4 commits into from

Conversation

peterwittek
Copy link

No description provided.

for i in xrange(N):
for j in xrange(N):
for k in xrange(N):
for i in range(N):
Copy link
Member

@kudkudak kudkudak Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will slow down code for Python2. I would use range from six module (http://pythonhosted.org/six/) which defaults to xrange for Python2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are talking about one single file where the xrange functions were replaced, we could simply do this:

try:
  range = xrange
except:
  pass

@@ -8,7 +8,7 @@
from pykernels.base import Kernel, GraphKernel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to use relative imports, I would keep it consistent, i.e. also change pykernels.base import to .base

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I don't have strong feelings either way, it is just the previous import scheme was broken in Python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants