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 vstinner
Recipients eric.snow, rhettinger, serhiy.storchaka, vstinner
Date 2015-09-03.14:03:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441289034.87.0.559016889822.issue24992@psf.upfronthosting.co.za>
In-reply-to
Content
> 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).
History
Date User Action Args
2015-09-03 14:03:54vstinnersetrecipients: + vstinner, rhettinger, eric.snow, serhiy.storchaka
2015-09-03 14:03:54vstinnersetmessageid: <1441289034.87.0.559016889822.issue24992@psf.upfronthosting.co.za>
2015-09-03 14:03:54vstinnerlinkissue24992 messages
2015-09-03 14:03:54vstinnercreate