This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Don't needlessly change refcounts of dummy objects for sets
Type: performance Stage:
Components: Interpreter Core Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, pitrou, python-dev, rhettinger, tim.peters
Priority: normal Keywords: patch

Created on 2013-08-21 07:55 by rhettinger, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
no_refcnt_dummy1.diff rhettinger, 2013-08-21 07:55 Use #ifdefs to remove dummy object refcount changes review
no_refcnt_dummy2.diff rhettinger, 2013-08-21 17:48 Version without #ifdef review
Messages (4)
msg195751 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-08-21 07:55
AFAICT, there is no reason for sets to incref and decref dummy objects.  The dummy object address is used as placeholders in the hash table but it is never accessed by set the logic.   As long the one reference is held at the time the dummy object is created, nothing further is served by the increfs and decrefs.

I can take them out entirely or use ifdefs to keep them for debug builds.

Does anyone know of any issues?
msg195753 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-21 08:14
I can't think of any counter-indication but I think we shouldn't distinguish between debug and non-debug mode. That way the debug hooks can check that the refcounting optimization is right.
msg195810 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-08-21 17:48
> I think we shouldn't distinguish between debug and non-debug mode.

That makes good sense.
Attaching a new patch without the #ifdefs.
msg195904 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-22 15:20
New changeset ac6dab1819c4 by Raymond Hettinger in branch 'default':
Issue 18797:  Remove unneeded refcount adjustments for dummy objects.
http://hg.python.org/cpython/rev/ac6dab1819c4
History
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 62997
2013-08-22 16:01:38rhettingersetstatus: open -> closed
resolution: fixed
2013-08-22 15:20:43python-devsetnosy: + python-dev
messages: + msg195904
2013-08-21 17:48:18rhettingersetfiles: + no_refcnt_dummy2.diff

messages: + msg195810
2013-08-21 08:14:28pitrousetmessages: + msg195753
2013-08-21 08:11:13pitrousetnosy: + tim.peters, Mark.Shannon
2013-08-21 08:05:04rhettingersetnosy: + pitrou
2013-08-21 07:55:45rhettingercreate