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.

Author serhiy.storchaka
Recipients abacabadabacaba, serhiy.storchaka
Date 2015-11-01.20:05:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The general solution is to make PyObject_Repr to detect recursive calls (as reprlib.recursive_repr does).

The straightforward way is to use thread local identity set. It can be implemented as a dict that maps id(obj) -> obj (creates an int object for key for every call, requires about 40-80 bytes for recurse level), or as specialized hash table (see Modules/hashtable.c) (faster, requires about 12-24 bytes for recurse level).

The fastest solution would be to set special flag inside proceeded object. For now general object has no place for such flag, but we can add it to GC head. On 64-bit this would increase the size of GC head from 24 to 32 bytes, on 32-bit there is a free place in 16-bytes GC head.

However the performance can be not critical here, because in any case repr() creates new object (resulting string). Using thread local hash table can be enough. In any case the patch will be enough complex to target it 3.6 only.
Date User Action Args
2015-11-01 20:05:17serhiy.storchakasetrecipients: + serhiy.storchaka, abacabadabacaba
2015-11-01 20:05:17serhiy.storchakasetmessageid: <>
2015-11-01 20:05:17serhiy.storchakalinkissue25455 messages
2015-11-01 20:05:17serhiy.storchakacreate