GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — gh-103740: Improve support of __slots__ for variable-length classes by serhiy-storchaka · Pull Request #141636 · python/cpython Conversation
|
|
Well.. that's weird. The docs still fail? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…e-103740.rXIj5h.rst Co-authored-by: Bénédikt Tran <[email protected]>
|
Thank you. I noticed this error yesterday (this is is the second time I make such error in a month), but it was already late night. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No worry! don't hesitate to ping in the future if you encounter other Sphinx errors! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I need a bit more time to review the code; sending docs suggestions in the meantime.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Petr Viktorin <[email protected]>
| For example, *__slots__* other than *__dict__* and *__weakref__* cannot | ||
| be defined on subclasses of :class:`int`, :class:`bytes`, or :class:`tuple`. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe use "they"?
| For example, *__slots__* other than *__dict__* and *__weakref__* cannot | |
| be defined on subclasses of :class:`int`, :class:`bytes`, or :class:`tuple`. | |
| For example, they cannot be defined on subclasses of | |
| :class:`int`, :class:`bytes`, or :class:`tuple`. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The only >>> class Meta(type): ... __slots__ = ['foo'] # now possible ... >>> class X(metaclass=Meta): ... def foo(self): return 'f' ... >>> X().foo <bound method X.foo of <__main__.X object at 0x7f7c579c2900>> >>> X.foo Traceback (most recent call last): File "<python-input-3>", line 1, in <module> X.foo AttributeError: 'Meta' object has no attribute 'foo' >>> X.foo = slice >>> X.foo(X()) slice(None, <__main__.X object at 0x7f7c5788c050>, None) >>> X().foo() 'f' Do we want to make this easier? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I did not have any use case for this feature, but this looks interesting. We already have data descriptors ( class Meta(type): @property def foo(self): return slice class X(metaclass=Meta): def foo(self): return 'f' print(X.foo(X())) print(X().foo()) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, descriptors are already weird. But given stdlib's non-usage of What about explicitly disabling arbitrary The |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Was not it the same with PEP 697? It allowed extending Anyway, I am only interesting in extending tuples. Adding support for special slots would be a side effect. Supporting |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
See #141755. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
PEP 697's “extending” was about adding a C-level chunk of memory, not about Python attributes. You can already extend Having a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The other half of this PR (very simple) has been moved to #141764. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Lets discuss this not in PRs, but in the issue #103740. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.