[issue43246] Dict copy optimization violates subclass invariant

2021-02-18 Thread Inada Naoki
Inada Naoki added the comment: I am not sure this should be fixed. If so, I think we should use PyDict_CheckExact() instead of PyDict_Check() && (tp_iter is overridden || keys() is overridden || sq_item is overridden). -- nosy: +rhettinger ___

[issue43246] Dict copy optimization violates subclass invariant

2021-02-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The choice of testing __iter__ was because OrderedDict overrides __iter__, and since dicts are ordered now, the order of insertion does matter. -- nosy: +serhiy.storchaka ___ Python tracker

[issue43246] Dict copy optimization violates subclass invariant

2021-02-18 Thread Phil
Change by Phil : -- nosy: +pgjones ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43246] Dict copy optimization violates subclass invariant

2021-02-17 Thread Inada Naoki
Change by Inada Naoki : -- nosy: +methane ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43246] Dict copy optimization violates subclass invariant

2021-02-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: The cause is in dict_merge (see here: https://github.com/python/cpython/blob/master/Objects/dictobject.c ); it has a fast path for when the object being merged in (which is what the dict constructor does; it makes an empty dict, then merges the provided

[issue43246] Dict copy optimization violates subclass invariant

2021-02-17 Thread Joshua Bronson
New submission from Joshua Bronson : If I understand correctly, it should be an invariant that in the code below, for all "Parent" classes, for all "method"s, Child1.method should return the same result as Child2.method: ``` class Parent: def __init__(self, value): self._value =