[David Abrahams] > The real reason to be able to introspect is so that you can handle both > kinds. Even if you're willing to destroy the data by examining it, if > you know you have a single-pass sequence, you might need to copy its > elements into a multi-pass sequence (e.g. file.lines()) in order to get > your work done. Note that Python uses PySequence_Fast() internally in such cases. This does whatever it takes to turn an iterable object into something that can be indexed at random via PySequence_Fast_GET_ITEM(fastseq, int_index). Under the covers it leaves lists and tuples alone, and materializes everything else into a temp tuple. I haven't felt a need for something fancier than that in practice; the lack of participation in this thread from other old-timers suggests they haven't either (piling on more protocols would allow to optimize some cases, but it's not clear such cases are important enough in Python Life to be worth the bother).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4