STINNER Victor added the comment: > If don't initialize fields, then they will be not initialized in odict_dealloc
Old code initialized all fields to zero (or NULL), like "_odict_FIRST(od) = NULL;". The type allocator fills the newly allocated with zeros. So setting fields again to zero is redundant (useless). > I would allocate a dict for od_inst_dict before calling PyDict_Type.tp_new. > An allocator can release GIL and call Python code, and at that moment the > OrderedDict object is in inconsistent state. Yes, but the newly created object is not still private at this point, there is only one reference known in the C code. dict_new() has the same design. You can please elaborate the issue? We only give the reference to the caller when the newly created OrderedDict is fully initialized (consistent). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24992> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com