Skip to content

Conversation

@carsonip
Copy link
Contributor

@carsonip carsonip commented Jan 17, 2020

Use empty slots for ABC classes, otherwise classes which inherit from them will still have __dict__. Also use __slots__ for more classes.


This change is Reviewable

Use empty slots for ABC classes, otherwise classes which inherit from them will still have __dict__. Also use __slots__ for more classes.
@carsonip
Copy link
Contributor Author

This saves ~200 bytes per object, because the object does not contain a __dict__, and there are also a marginal performance gain:

python benchmarks/record_batch_read.py 

before:

..................... batch_read_v0: Mean +- std dev: 1.23 ms +- 0.06 ms ..................... batch_read_v1: Mean +- std dev: 1.28 ms +- 0.10 ms ..................... batch_read_v2: Mean +- std dev: 961 us +- 82 us 

after:

..................... batch_read_v0: Mean +- std dev: 1.18 ms +- 0.05 ms ..................... batch_read_v1: Mean +- std dev: 1.20 ms +- 0.06 ms ..................... batch_read_v2: Mean +- std dev: 950 us +- 55 us 
Copy link
Contributor

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

@jeffwidman jeffwidman merged commit d54aaf6 into dpkp:master Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants