Just because you _can_ add `__dict__` to `__slots__` doesn't mean you should, or that there is any good reason to.
– agfSep 28 '11 at 15:11
`__Slots__` and `__dict__` are different. You have got the basic concept right. This post might help you:
http://stackoverflow.com/questions/472000/python-slots Hope that helps :)
– varunlSep 28 '11 at 15:14
`__slots__` also creates descriptors that make attribute access faster. Having `__dict__` in `__slots__` will still create a dictionary and allow dynamic attributes, but accessing them will be (very) slightly faster. (Sorry for poking an old thread, I felt like the accepted answer was insufficient)
– ExaJul 10 '20 at 02:18
1 Answers1
4
Yes. If you want __dict__, then just don't use __slots__.
http://stackoverflow.com/questions/472000/python-slots Hope that helps :) – varunl Sep 28 '11 at 15:14