We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
5.3. Tuples and Sequences should have the explanation of the indirect way of tuple comprehensions as shown below:
Tuple comprehensions are not supported but if you really want them, do this with tuple() as shown below:
squares = tuple(x**2 for x in range(10))
The text was updated successfully, but these errors were encountered:
Tuple comprehensions are not supported but if you really want them, do this with
Tuple docs says you can construct them from iterable, that means support for comprehensions: https://docs.python.org/3/library/stdtypes.html#tuple
Though, I don't see why this should be in the Tutorial. It doesn't mention even the tuple constructor.
Sorry, something went wrong.
This is faster: tuple([x**2 for x in range(10)])
tuple([x**2 for x in range(10)])
I agree.
Interesting, I got ~x2 speedup on my system even for smaller ranges (when PySequence_Tuple() uses _PyTuple_FromArraySteal()).
PySequence_Tuple()
_PyTuple_FromArraySteal()
I'm closing this, based on Raymond's teaching experience.
skirpichev
No branches or pull requests
5.3. Tuples and Sequences should have the explanation of the indirect way of tuple comprehensions as shown below:
Tuple comprehensions are not supported but if you really want them, do this with tuple() as shown below:
The text was updated successfully, but these errors were encountered: