-----Original Message-----
From: Ben Rudiak-Gould <benrud...@gmail.com>
Sent: 14 June 2020 22:59
To: Jonathan Fine <jfine2...@gmail.com>
Cc: python-ideas <python-ideas@python.org>
Subject: [Python-ideas] Re: For quicker execution, don't refcount objects that
can't be deleted
There isn't really any contention for these memory locations in CPython as it
stands because only one interpreter thread can run at a time. The only time a
cache handoff is needed is during a thread switch when the new thread is
scheduled on a different core, which is pretty rare (at CPU timescales). Adding
checks to every incref/decref would probably cost more time than it would save.
Something that might help performance a bit, and wouldn't hurt it, would be to
drop explicit calls of Py_{INC,DEC}REF(Py_{None,False,True,...}), such as the
ones in Py_RETURN_{NONE,FALSE,TRUE}, making these objects' refcounts into
freefloating meaningless values. The refcounts would be initially set to a
value far from zero, and on the rare occasions that they hit zero, the dealloc
functions would just set them back to the initial value. Whether this would
save enough time to be worth it, I don't know.
(To avoid signed wraparound undefined behavior, you'd have to either change the
refcount type from ssize_t to size_t, or else keep the DECREF calls and set the
initial value to something like
PY_SSIZE_T_MAX/2.)
[Steve Barnes]
Of course if we had a NaN value for integers, int('NaN'), then we could just
set the initial count to it and since NaN - anything = NaN all would be golden.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/PI4R4WAIADD2OBSCVQNSORYBMA3TRP4P/
Code of Conduct: http://python.org/psf/codeofconduct/