04.10.20 01:06, Guido van Rossum пише: > On Sat, Oct 3, 2020 at 9:28 AM Serhiy Storchaka <[email protected] > <mailto:[email protected]>> wrote: > The code of object.__dir__() is very old, it predates new-style classes, > and currently it gathers names using different algorithm than used in > object.__getattr__(), so object.__dir__() does not always return a list > of names accepted by object.__getattr__(). > Would anything break if we changed `dir()` to use `__mro__` instead of > `__bases__`? It would probably be simpler.
It is what I planned to play with. Also we can consider using _PyObject_GetDictPtr() instead of resolving the __dict__ attribute and Py_TYPE() instead of resolving the __class__ attribute. > > I think all that hackery may predate (and may even have been an > > inspiration for features of) new-style classes. > I wonder whether it should pass with Python 2. > I suppose you meant "pass" as in "die". I agree. Do we need a deprecation period? _______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/PGK7OYU2XAFUTDIYPLG6O5PJGRU5J2D6/ Code of Conduct: http://python.org/psf/codeofconduct/
