[issue44318] Asyncio classes missing __slots__

2022-03-12 Thread Andrew Svetlov
Andrew Svetlov added the comment: 1. Guido van Rossum explicitly designed asyncio to *don't* use slots. 2. Changing it produces potential backward incompatibility issues. Very many stdlib classes don't have slots, as already mentioned. The default is really the reverse: no slots. Closing. --

[issue44318] Asyncio classes missing __slots__

2021-06-17 Thread Andrei Kulakov
Andrei Kulakov added the comment: My mistake, I forgot the size of the dict itself is not included in getsizeof(). -- ___ Python tracker ___ __

[issue44318] Asyncio classes missing __slots__

2021-06-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: Andrei: The size of an instance of Semaphore is 48 bytes + 104 more bytes for the __dict__ containing its three attributes (ignoring the cost of the attributes themselves). A slotted class with three attributes only needs 56 bytes of overhead per-instance (i

[issue44318] Asyncio classes missing __slots__

2021-06-17 Thread Andrei Kulakov
Andrei Kulakov added the comment: The size of an instance of Semaphore is 48, of an empty tuple is 40, of a small int is 28, of an instance of a normal class with a single slot in __slots__ is also 40, are you use 48 byte size will really be an issue for you? --

[issue44318] Asyncio classes missing __slots__

2021-06-17 Thread Bluenix
Bluenix added the comment: My exact use-case is that I am subclassing asyncio.Semaphore to change some functionality (override `release()` to do nothing and set up tasks to schedule calls to reset the counter). I am expecting *a lot* of these instances so (like Serhiy Storchaka nicely put it

[issue44318] Asyncio classes missing __slots__

2021-06-16 Thread Andrei Kulakov
Andrei Kulakov added the comment: Bluenix, can you describe your use case in more detail? -- nosy: +andrei.avk ___ Python tracker ___ _

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread Bluenix
Bluenix added the comment: >>> (1).__dict__ Traceback (most recent call last): File "", line 1, in AttributeError: 'int' object has no attribute '__dict__' >>> 4.5.__dict__ Traceback (most recent call last): File "", line 1, in AttributeError: 'float' object has no attribute '__dict__' >>

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread wyz23x2
Change by wyz23x2 : -- nosy: -wyz23x2 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.or

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread wyz23x2
wyz23x2 added the comment: OK, so: >>> (1).__slots__ Traceback (most recent call last): File "", line 1, in AttributeError: 'int' object has no attribute '__slots__' >>> 4.5.__slots__ Traceback (most recent call last): File "", line 1, in AttributeError: 'float' object has no attribute '_

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread Bluenix
Bluenix added the comment: > What is the problem with this? The problem is that asyncio *is not* defining __slots__. > Setting __slots__ in base class is required if you want to get a benefit of > setting __slots__ in any of subclasses. That is my use-case for this. -- ___

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What is the problem with this? Setting __slots__ is needed if we want to save memory for creating a lot of instances. It can also be used for preventing adding arbitrary attributes and/or making weak references. Setting __slots__ in base class is required

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread Bluenix
New submission from Bluenix : Most of asyncio's classes are missing a __slots__ attribute - for example Lock, Event, Condition, Semaphore, BoundedSemaphore all from locks.py; or Future, FlowControlMixin, Queue, BaseSubprocessTransport from various other parts of asyncio. -- component