I'm +1 on disallowing strings specifically. The unexpected behaviour that ensues if you try to iterate over a class's slots is a footgun that I've trodden on a few times, and it's always been annoying.
But I don't see any particular reason to disallow any other kind of iterable, and I'm definitely -1 on disallowing using a dictionary for __slots__. Using a dictionary for __slots__ as a way to document attributes is a feature I very much like. Best, Alex > On 18 Mar 2022, at 20:59, Guido van Rossum <gu...@python.org> wrote: > > >> On Fri, Mar 18, 2022 at 9:40 AM Paul Bryan <pbr...@anode.ca> wrote: >>> On Fri, 2022-03-18 at 09:35 -0700, Guido van Rossum wrote: >>> The motivation has been explained already. >> >> In this thread? > > Yes, Eric's message. > >>> What on earth did your test do that got a speedup by using sets? Was it >>> repeatedly checking whether a variable was in a slot? The other thing this >>> does is rearrange the order in which slots appear from run to run (since >>> set order is affected by hash randomization) and you might have gotten >>> lucky with a popular attribute being moved to the front, where it's more >>> likely to be in the memory cache already (cache lines being 64 bytes and >>> pointers being 8 bytes nowadays). >> >> I created objects in a tight loop, populating attributes, noting the elapsed >> time. > > It does not make sense that that is correlated to the type of __slots__, > since __slots__ is not used for instance creation at all (it is only used to > create the class). I stick to my likely explanation. > > Regarding Serhiy's proposal, I'm +0 on disallowing strings, and +0 on > disallowing things that can't be reiterated (but it's not a problem in > practice). Given other responses the status quo is likely best. > > -- > --Guido van Rossum (python.org/~guido) > Pronouns: he/him (why is my pronoun here?) > _______________________________________________ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/EYZ32GBU4QUTRPU26BDCYYMKG4GX633N/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/PO32SWLW27Y2MUWROXD7UUPTUTXTDEEE/ Code of Conduct: http://python.org/psf/codeofconduct/