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 eric.snow, rhettinger, serhiy.storchaka
Date 2015-10-15.08:05:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1444896308.75.0.718152743923.issue25410@psf.upfronthosting.co.za>
In-reply-to
Content
Proposed patch cleans up and fixes minor bugs in C implementation of OrderedDict.

1. Used the "p" format unit instead of manual calling PyObject_True() for parsing boolean parameters.

2. Used _Py_Identifier private API instead of char* API if appropriate.

3. Used Py_TYPE instead of the __class__ attribute as in other extension types.

4. Fixed od_fast_nodes size calculation in  __sizeof__().

5. Simplified __reduce__() taking into account that __dict__ is empty in C implementation of OrderedDict.

6. popitem() with wrong number of arguments now raises TypeError instead of KeyError for empty dictionary.

7. Python implementation of move_to_end() calls key comparing only once in common case. C implementation called key comparing twice, it first compares a key with first or last key. Now C implementation calls key comparing only once in common case.

8. Used PyUnicode_FromFormat() instead of str.__mod__ in __repr__().

9. update() now takes into account that args and kwargs are always tuple and dict (if not NULL).

10. Got rid of PyMapping_Items() in update(). PyMapping_Items() creates a copy of items as a list, this is not needed.

Also applied other cleanups. The size of sources is decreased by 105 lines.

 Objects/odictobject.c |  194 +-----------------------------!!!!!!!!!!!!!!!!!!
 1 file changed, 6 insertions(+), 111 deletions(-), 77 modifications(!)
History
Date User Action Args
2015-10-15 08:05:09serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, eric.snow
2015-10-15 08:05:08serhiy.storchakasetmessageid: <1444896308.75.0.718152743923.issue25410@psf.upfronthosting.co.za>
2015-10-15 08:05:08serhiy.storchakalinkissue25410 messages
2015-10-15 08:05:07serhiy.storchakacreate