Skip to content

Slots for all of .rest classes

Pre-release
Pre-release
Compare
Choose a tag to compare
@hexatester hexatester released this 17 Jan 16:58
· 434 commits to master since this release

The special attribute __slots__ allows you to explicitly state which instance attributes you expect your object instances to have, with the expected results:

  1. faster attribute access.
  2. space savings in memory.

The space savings is from

  1. Storing value references in slots instead of __dict__
  2. Denying __dict__ and __weakref__ creation if parent classes deny them and you declare __slots__.