mark wrote: > > so in other words, this construct is more than 4 times faster > > than plain use of PySequence_GetItem. >=20 > Good stuff! >=20 > > guess it's time to fix a couple of things in PIL... >=20 > Its a fair bit of code to duplicate everywhere you want the speed = increase. > How can we add a similar scheme to the core, so the changes people = need to > make are trivial (to the point where the change is zero!)? the first part is trivial; just add something like this to Objects/abstract.c: PyObject* PySequence_TupleOrList(PyObject* seq) { if (PyList_Check(seq) || PyTuple_Check(seq)) Py_INCREF(seq); else if (PySequence_Check(seq)) seq =3D PySequence_Tuple(seq); else { PyErr_SetString(PyExc_TypeError, "argument must be a sequence"); seq =3D NULL; } return seq; } 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... </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