-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Tuple comprehension is not supported #108
Comments
For what it's worth, there is no such thing as a tuple comprehension. |
however, this is a bit hard to impl for some reason. |
Yes, generators are a big pain to implement. And they are slow if done the naive way :/ |
Hello, I have had an idea to implement generator expressions. Let's take this python code as a start:
Of course it will go through all numbers and finally print True. The idea would be basically to internally transform this code into:
Of course the function What do you think about it? In fact, the functions
But it is going to create a list with a million of items! I have tried to implement my idea, and I don't think it's so naive.
If I disassemble the generator code alone in CPython (I need to do it separately), I get this:
If I disassemble f in pocketpy with my own implementation of the feature, I get this:
I don't feel it that bad. I have the impression to be reasonably close. Interestingly, it looks like CPython pass What are your thoughts? Thank you for reading. |
In fact, if you are processing very large number of iterations, you can use yield or class with |
And in pkpy list comprehension is recommended though it creates a list. Because a function with yield, in most cases, is slower than listcomp or for loop. |
Finally, the idea is not about all/any. Our parser is not able to recognize generator expression for some history reasons. |
No description provided.
The text was updated successfully, but these errors were encountered: