>>>>> "FL" == Fredrik Lundh <effbot@telia.com> writes: FL> has anyone benchmarked the abstract sequence API? how much FL> slower is it? would it be a good idea to treat lists as a FL> special case, to avoid slowing down existing code? The abstract interface is fairly expensive. The current code uses PyList_GET_ITEM to access the elements of the list. The abstract interface adds two function calls (PySequence_GetItem, PyList_GetItem). The first function just does a couple of sanity checks (verify arg is sequence & that it has get_item). The second function verifies that the arg is a list, then does a bounds check. None of the work that either of these functions does is necessary for the list case! In the extended call syntax implementation, I used PySequence_Tuple to handle non-standard sequences. Once converted to a tuple, they can be processed using the macros. If you support user-defined sequences, the sanity checking can get pretty hairy if you don't coerce to a tuple; e.g. the PySequence_Length method can lie! I don't remember considering the cost of allocating the new tuple, which is only used internally. Jeremy
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