Tuple from iterable #4128
Unanswered
kevinhartman
asked this question in
Questions
Replies: 1 comment 2 replies
-
You can call |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I frequently find myself writing code like this to efficiently build a tuple from an iterable:
Is there a better way to do this? As I understand it, downcasting should be faster if
seq
is actually already a tuple (callingtuple()
on something in CPython is a no-op I believe if the thing is already a tuple, and I'd like those semantics here.(FWIW, I realize this code could probably be even faster if I were to skip the
is_instance_of
check and instead handle thePyResult
returned fromdowncast_exact
.)Beta Was this translation helpful? Give feedback.
All reactions