The worse offender is probably not Py_TYPE() but reference counting.
Just like switching to atomic reference counting slows down Python by 20% to 40% (according to various attempts by various people), it's not difficult to imagine that adding a conditional branch in the critical paths of Py_INCREF() and Py_DECREF() would significantly slow down Python as well.
So, if you want tagged pointers without slowing everything other than small integer arithmetic, you probably need to ditch reference counting as well. And then, perhaps you should start by ditching reference counting, because that's much more ambitious and complicated than implementing tagged pointers ;-)
Le 12/09/2018 à 23:25, Neil Schemenauer a écrit :
On 2018-09-12, Stefan Behnel wrote:
So, if the goal is to make this common operation slow, what alternative do you envison for getting back an "almost no cost" type check?
Off the top of my head, I think you can have a C99 inline function, like Py_IsType(ob, tp). If you build with tagged pointers turned off, there is no cost compared to what we currently do. If you turn them on, there is an extra check on the low bits of the pointer and a branch. Not sure that qualifies as "almost no cost" but seems not bad to me.
Neil _______________________________________________ capi-sig mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com