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

Regression due to PyDict_Next optimization #634

Closed
robertwb opened this issue Nov 19, 2008 · 9 comments
Closed

Regression due to PyDict_Next optimization #634

robertwb opened this issue Nov 19, 2008 · 9 comments

Comments

@robertwb
Copy link
Contributor

These changesets introduce a code generation bug that causes repeated dictionary iteration to fail (using Python 2.6 on 32- and 64-bit Ubuntu 8.04):

changeset:   1344:7a102bc50f8f
user:        Stefan Behnel <scoder@users.berlios.de>
date:        Sun Nov 16 22:45:33 2008 +0100
summary:     integrate new iter-dict transform

changeset:   1343:db3eb81258f4
user:        Stefan Behnel <scoder@users.berlios.de>
date:        Sun Nov 16 22:45:12 2008 +0100
summary:     new transform that converts for-in-dict.iter*() into a while-loop over PyDict_Next(), which makes the loop 30-50% faster

The attached test case demonstrates the problem.

At 2008-11-19T21:38:59Z jasone added attachment foo.pyx

At 2008-11-20T18:30:58Z jasone added attachment PyDict_Next

Migrated from http://trac.cython.org/ticket/123

@robertwb
Copy link
Contributor Author

jasone commented

The attached patch fixes iteration by using a local temporary variable, rather than using the iterator counter. I think the real problem is that some tree tranform is removing the node that initializes the iterator counter (perhaps it's viewed as a redundant global variable initialization), but finding that problem is beyond my understanding of Cython at this point.

@robertwb
Copy link
Contributor Author

scoder changed owner from somebody to scoder
commented

@robertwb
Copy link
Contributor Author

scoder changed owner from scoder to empty
commented

Yes, it looks like a problem with the initialisation. The same temp node gets reused here, but it's only initialised once.

I applied your work-around by now, but the real problem is elsewhere in the temp code.

@robertwb
Copy link
Contributor Author

@dagss commented

I have now changed IteratorNode so that the counter is considered an implementation detail/"temp register", rather than a subnode in the tree. Thus it shouldn't be used by transforms, and the consequence is that this patch now does the entirely correct thing.

I recommend closing as "fixed", but waiting for review.

@robertwb
Copy link
Contributor Author

robertwb commented Nov 29, 2008

@dagss commented

See http://trac.cython.org/ticket/124 for relevant patches.

@robertwb
Copy link
Contributor Author

scoder changed resolution to fixed
status from new to closed
commented

Yes, that's the right thing to do.

@robertwb
Copy link
Contributor Author

@robertwb changed resolution from fixed to empty
status from closed to reopened
commented

@robertwb
Copy link
Contributor Author

@robertwb changed owner to jasone
status from reopened to new
commented

@robertwb
Copy link
Contributor Author

@robertwb changed resolution to fixed
status from new to closed
commented

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

No branches or pull requests

1 participant