Martin v. Löwis <mar...@v.loewis.de> added the comment: > Unfortunately, the check is O(n), so it can get a little expensive.
Not in the typical case, I guess. *If* you have to go through all objects, then likely you end up untracking the object. If you can't untrack, you typically find a tracked object in the content quickly. > I suppose that's no worse than traversing the tuple to look for a cycle, > though. Correct. Collection is O(n) per object, anyway. > Perhaps it could be done at the same time? > Can _PyObject_GC_UNTRACK() be safely called from tp_traverse? No. However, I doubt that iterating over the object twice is significantly slower than iterating over it once and performing both checks. Plus, the check for tracked elements can return as soon as one such object is found. _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4688> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com