the eff-bot wrote: > the first part is trivial; just add something like this to > Objects/abstract.c: >=20 > PyObject* > PySequence_TupleOrList(PyObject* seq) > ... >=20 > the second parts is harder -- and that's of course where the > real performance boost comes from. as far as I'm aware, very > few C compilers can "specialize" loops for you... in the same test setup, moving the PyList_Check inside the loop gives a 25-30% slowdown (or to look at it from the other side, 3 times instead of 4 times faster than naive code). a compromise solution could be to combine the above function with a macro: #define PySequence_TupleOrList_GET_ITEM(seq, index)\ (PyList_Check(seq) ? PyList_GET_ITEM(seq, index) :\ PyTuple_GET_ITEM(seq, index) (anyone got a better name? ;-) standard usage: seq =3D PySequence_TupleOrList(seq_in); size =3D PyObject_Length(seq); =20 for (i =3D 0; i < size; i++) { PyObject* obj =3D PySequence_TupleOrList_GET_ITEM(seq, i); ... } comments? </F>
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