Skip to content
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

Don't use __slots__ #223

Closed
techtonik opened this issue Jan 3, 2015 · 6 comments
Closed

Don't use __slots__ #223

techtonik opened this issue Jan 3, 2015 · 6 comments
Labels

Comments

@techtonik
Copy link

The only useful application of __slots__ in Python is for heavy performance optimization. GitPython performance bottleneck is in external calls, so __slots__ won't help it. If you want to protect visibility of internal methods, use __ prefix. Slots are an impediment - #222

See also https://stackoverflow.com/questions/472000/python-slots and http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/

@techtonik techtonik changed the title Don Don't use __slots__ Jan 3, 2015
@Byron Byron added the rejected label Jan 3, 2015
@Byron
Copy link
Member

Byron commented Jan 3, 2015

They are especially bad when multi-inheritance kicks in, as they will become ineffective if one base doesn't have slots, or downright prevent multi-inheritance.
When they are in effect, they help preventing accidental creation of attributes, and additionally reduce the object's memory footprint. Besides, of course, documenting used instance variables.

As #222 can easily be circumvented, I see no need to remove slots everywhere though.

@Byron Byron closed this as completed Jan 3, 2015
@techtonik
Copy link
Author

I'd argue that this is an easy circumvention. The proper fix is to implement a real debugging interface in GitPython that doesn't rely on hacking through environment variables (which are hard to set in some contexts, such as when running a script from an editor).

@Byron
Copy link
Member

Byron commented Jan 3, 2015

As it seems to be a 'hack' to set a class member, as well as to use environment variables in general, there seems to be no way you can use the existing debugging interface.
If you come up with something that suits your liking, please feel free to post it here, maybe it gets implemented.
Thanks

@techtonik
Copy link
Author

The idea way is to define an application level debug switch that can be turned on and off as desired.

@Byron
Copy link
Member

Byron commented Jan 4, 2015

Thank you, but what is the API you have in mind or that you are used to ? Could you make an example ?
Are we talking about a fancy way to hide the fact that a class variable is set under the hood ?

import git
last_val = git.set_debugging(None|True|'full')
...
git.set_debugging(last_val)

@techtonik
Copy link
Author

x = Git(...)
x.debug = True

Will be enough for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants