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

Overloaded bytes transformer #2

Closed
wants to merge 3 commits into from

Conversation

ssanderson
Copy link
Collaborator

Adds an overloaded bytes transformer that accepts a callable to apply over bytes literals in the decorated function.

Avoids using consts as dict keys by using id(obj) as hash keys instead,
and using a second dict mapping id(obj) -> obj.
def visit_consts(self, consts):
return super().visit_consts(
tuple(
self.visit_consts(const) if isinstance(const, tuple)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@llllllllll it's possible that recursing through tuples like this should be the default behavior.

Copy link
Owner

Choose a reason for hiding this comment

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

do you mean default in codetransformer? Why, this doesn't make sense in lazy. I think that this is needed in this case and the float case.

You do need to look through frozensets though because of the peephole optimizer.

In [1]: def f():
   ...:     return a in {1.0, 2.0}
   ...: 

In [2]: f.__code__.co_consts[3]
Out[2]: frozenset({1.0, 2.0})

@ssanderson
Copy link
Collaborator Author

superceded by #3

@ssanderson ssanderson closed this Jun 23, 2015
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.

None yet

2 participants