homepage

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 methane
Recipients mbussonn, methane, ned.deily, python-dev, skrah, vstinner, xiang.zhang
Date 2016年09月13日.00:20:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473726038.21.0.996035996416.issue28040@psf.upfronthosting.co.za>
In-reply-to
Content
> So what if we delete mp->ma_used == ix or use mp->ma_keys->dk_nentries == ix? Do we still have any case breaking the order?
Yes. `mp->ma_used == ix` means no more guard about key ordering.
class C:
 ...
a, b = C()
a.a, a.b = 1, 2 # shared key order is [a, b]
# b has [a, b] pending slot too, and no guard when inserting pending slot.
b.b, b.a = 3, 4 # continue to using sharing key
assert list(b.__dict__.keys()) == ['b', 'a']) # AssertionError!
---
`mp->ma_keys->dk_nentries == ix` is nonsense. It prohibits to inserting pending slot:
a, b = C()
a.a, a.b = 1, 2 # shared key order is [a, b]
# Since ma_keys is shared, b's dk_nentries == 2
b.a = 3 # ix = 0, dk_nentries = 2; stop using sharing keys.
---
To keep using sharing key, my idea is adding one more member to dict: mp->ma_values_end.
When inserting to pending or empty slot, check that `ix >= mp_ma_values_end` to ensure ordering
and `set mp->ma_values_end = ix+1` if it's OK.
a, b = C() # Both of ma_values_end = 0
a.a, a.b = 1, 2 # shared key order is [a, b], a's ma_values_end = 2
b.b = 3 # ma_values_end (=0) <= ix (=1); OK; set ma_values_end = 2
b.a = 4 # ma_values_end (=2) > ix (=0); NG; convert to combined table
But testing such an implementation detail is hard from pure Python. (No API for checking ma_values_end,
the dict is split or combined, and two dict share keys).
I don't know adding such hack is worth enough.
Dict is made by tons of hacks, you know.
I think new OrderedDict implementation based on new dict implementation is more worth.
If dict is far more efficient than OrderedDict, people may use dict even when OrderedDict should be used.
But I don't know it can be done after beta1.
History
Date User Action Args
2016年09月13日 00:20:39methanesetrecipients: + methane, vstinner, ned.deily, skrah, python-dev, xiang.zhang, mbussonn
2016年09月13日 00:20:38methanesetmessageid: <1473726038.21.0.996035996416.issue28040@psf.upfronthosting.co.za>
2016年09月13日 00:20:38methanelinkissue28040 messages
2016年09月13日 00:20:35methanecreate

AltStyle によって変換されたページ (->オリジナル) /