incorrect `__slots__`
cwells opened this issue · 3 comments
cwells commented
I'm presuming this was intended to be GRANULARITY
:
Line 65 in 5facdd5
Confusing when dir(rate)
shows a non-existent attribute.
alisaifee commented
Actually it shouldn't be GRANULARITIES
since that is a class, not instance var.
alisaifee commented
Thanks for the report, turns out the current implementation (even if we ignore the extra granularities
slot), was actually
causing the objects to be as large as if they would be without __slots__
No Slots
>>> from pympler.asizeof import asizeof
>>> from limits import parse_many
>>> asizeof(parse_many(",".join(["1/second"] * 100000))) / 1024.0 / 1024.0
15.259986877441406
Slots declared on base class
>>> from pympler.asizeof import asizeof
>>> from limits import parse_many
>>> asizeof(parse_many(",".join(["1/second"] * 100000))) / 1024.0 / 1024.0
15.259811401367188
With slots declared on derived class (RateLimitIterPerSecond
etc..)
>>> from pympler.asizeof import asizeof
>>> from limits import parse_many
>>> asizeof(parse_many(",".join(["1/second"] * 100000))) / 1024.0 / 1024.0
6.1045379638671875