-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JOSS] Slots #20
Comments
Hi @Sulstice, I used it to save RAM if someone wants to create objects with thousands of atoms, since default Python uses a You can try this yourself (I found a nice example here): slots.py class MyClass(object):
__slots__ = ['name', 'identifier']
def __init__(self, name, identifier):
self.name = name
self.identifier = identifier
num = 1024*256
x = [MyClass(1,1) for i in range(num)] noslots.py class MyClass(object):
def __init__(self, name, identifier):
self.name = name
self.identifier = identifier
num = 1024*256
x = [MyClass(1,1) for i in range(num)] We can check the memory usage with this excellent tool. The difference between both shows the memory aspect of |
May I suggest to change the variable |
OK, I changed |
I think this can be closed since the main question (why using |
Forgive me but it's been awhile since I've seen the
__slots__
argument. I remember some of the numpy folk arguing about it at the last PyData conference.In
src/kallisto/atom.py
, Line 52.Here's what I'm looking at, can you elaborate on your reason for choosing slots, and does it actually make access to your class attributes access that much faster?
The text was updated successfully, but these errors were encountered: