[issue480562] replace __slots__ with addmembers

2022-04-10 Thread admin
Change by admin : -- github: None -> 35504 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue520644] __slots__ are not pickled

2022-04-10 Thread admin
Change by admin : -- github: None -> 36129 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue489581] __slots__ leak!!!

2022-04-10 Thread admin
Change by admin : -- github: None -> 35672 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue519621] __slots__ may lead to undetected cycles

2022-04-10 Thread admin
Change by admin : -- github: None -> 36122 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue502544] __slots__ undocumented

2022-04-10 Thread admin
Change by admin : -- github: None -> 35909 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue496240] __slots__ does not iterate over a string

2022-04-10 Thread admin
Change by admin : -- github: None -> 35821 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-03-14 Thread Jason R. Coombs
Change by Jason R. Coombs : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[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.

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-03 Thread Mark Shannon
Change by Mark Shannon : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-03 Thread Mark Shannon
Mark Shannon added the comment: New changeset 751c9ed801ad1189272ca10f0749bfc9d49b5038 by Mark Shannon in branch 'main': bpo-46891: Fix creating a new instance of a module subclass with slots (GH-31643) https://github.com/python/cpython/commit/751c9ed801ad1189272ca10f0749bfc9d49b5038

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-02 Thread Ronald Oussoren
Ronald Oussoren added the comment: I don't feel qualified to review the PR, but can confirm that this PR fixes this issue as well as the crash in PyObjC that I extracted my reproducer from. -- ___ Python tracker

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-02 Thread Mark Shannon
Change by Mark Shannon : -- keywords: +patch pull_requests: +29763 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/31643 ___ Python tracker

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-02 Thread Mark Shannon
Mark Shannon added the comment: Dennis, thanks for bisecting this. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-02 Thread Mark Shannon
Change by Mark Shannon : -- assignee: -> Mark.Shannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-02 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Marking this as release blocker. -- priority: normal -> release blocker ___ Python tracker ___

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-02 Thread Ronald Oussoren
Ronald Oussoren added the comment: @Pablo: this is a possible release blocker, hard crash for code that works in earlier releases. That said, I have a workaround on my end and IMHO a fix could wait for the next alpha. -- nosy: +pablogsal ___

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-01 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +Mark.Shannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-01 Thread Dennis Sweeney
Dennis Sweeney added the comment: Bisected to here: c3f52b4d707a78eb342372a2be00f3eb846a05b9 is the first bad commit commit c3f52b4d707a78eb342372a2be00f3eb846a05b9 Author: Mark Shannon Date: Wed Jun 23 10:00:43 2021 +0100 bpo-44486: Make sure that modules always have a dictionary.

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-01 Thread Ronald Oussoren
Ronald Oussoren added the comment: The debug build seems to indicate that slot memory is not initiated properly, a stack trace (note the argument to visit_validate at frame #7): * frame #0: 0x00019b60d9b8 libsystem_kernel.dylib`__pthread_kill + 8 frame #1: 0x00019b640eb0

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-01 Thread Ronald Oussoren
Ronald Oussoren added the comment: The crash itself happens during garbage collection: % python3.11 -Xdev t.py (master)pyobjc-8 Fatal Python error: Segmentation

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-01 Thread Ronald Oussoren
Ronald Oussoren added the comment: This is with python 3.11 alpha 5 using the installer for macOS. -- ___ Python tracker ___ ___

[issue46891] Crash in ModuleType subclass with __slots__

2022-03-01 Thread Ronald Oussoren
New submission from Ronald Oussoren : The following crashes the interpreter in Python 3.11, and works fine in older versions: # --- script.py import types class MyModule (types.ModuleType): __slots__ = ( "_MyModule__a", "_MyModule__b", ) def

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-02-10 Thread miss-islington
miss-islington added the comment: New changeset 1124ab6d1d15dc5058e03b63fd1d95e6f1009cc3 by Miss Islington (bot) in branch '3.10': bpo-46246: add missing __slots__ to importlib.metadata.DeprecatedList (GH-30452) https://github.com/python/cpython/commit

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-02-10 Thread miss-islington
Change by miss-islington : -- pull_requests: +29433 pull_request: https://github.com/python/cpython/pull/31269 ___ Python tracker ___

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-02-10 Thread miss-islington
miss-islington added the comment: New changeset dd76b3f7d332dd6eced5cbc2ad2adfc397700b3d by Arie Bovenberg in branch 'main': bpo-46246: add missing __slots__ to importlib.metadata.DeprecatedList (GH-30452) https://github.com/python/cpython/commit/dd76b3f7d332dd6eced5cbc2ad2adfc397700b3d

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-02-10 Thread Jason R. Coombs
Jason R. Coombs added the comment: I'm pretty sure both EntryPoints and DeprecatedList were introduced in Python 3.10, so 3.9 and 3.8 aren't relevant. -- versions: -Python 3.8, Python 3.9 ___ Python tracker

[issue46550] __slots__ updates despite being read-only

2022-02-02 Thread Ronald Oussoren
Ronald Oussoren added the comment: There's a use case for using a dict for __slots__, pydoc will use a dict value for the slots as a mapping from attribute name to attribute documentation. Because of that it is not really worthwhile to transform the value of __slots__ during class

[issue46550] __slots__ updates despite being read-only

2022-02-02 Thread Ronald Oussoren
Ronald Oussoren added the comment: W.r.t. augmented assignments, this is a good blog post about how they work under the hood: https://snarky.ca/unravelling-augmented-arithmetic-assignment/ -- ___ Python tracker

[issue46550] __slots__ updates despite being read-only

2022-01-28 Thread Eryk Sun
8 LOAD_CONST 0 (1) 10 BINARY_OP 13 (+=) 12 ROT_TWO 14 STORE_ATTR 1 (a) 16 LOAD_CONST 1 (None) 18 RETURN_VALUE Note the STORE_ATTR instruction in the above bytecode. As

[issue46550] __slots__ updates despite being read-only

2022-01-28 Thread Ian Lee
Ian Lee added the comment: @ronaldoussoren - right, I agree that I think that raising the AttributeErrors is the right thing. The part that feels like a bug to me is that the exception is saying it is read only and yet it is not being treated it that way (even though as you point out, the

[issue46550] __slots__ updates despite being read-only

2022-01-28 Thread Ronald Oussoren
Ronald Oussoren added the comment: Python's is behaving as expected here (but see below): the slots definition tells the interpreter which attribute names can be set on an instance and "__slots__" is not one of those attributes in your code. "a.__slots__ += ...&qu

[issue46550] __slots__ updates despite being read-only

2022-01-27 Thread Eryk Sun
Eryk Sun added the comment: Please read about augmented assignment [1]. In the REPL, use help("+="). An augmented assignment evaluates the target (which, unlike normal assignment statements, cannot be an unpacking) and the expression list, performs the binary operation specific to

[issue46550] __slots__ updates despite being read-only

2022-01-27 Thread Ian Lee
26 2022, 20:56:53) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... __slots__ = ('x',) ... >>> a = A() >>> a.__slots__ ('x',) >>> a.__slots__ += ('y

[issue46550] __slots__ updates despite being read-only

2022-01-27 Thread Nikita Sobolev
Nikita Sobolev added the comment: It does not happen on `3.11` (main): ``` Python 3.11.0a4+ (heads/main-dirty:ef3ef6fa43, Jan 20 2022, 20:48:25) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin Type "help", "copyright", "credits" or "license" for more i

[issue46550] __slots__ updates despite being read-only

2022-01-27 Thread Ian Lee
Python 3.10.2 (main, Jan 26 2022, 20:07:09) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class A(object): ... __slots__ = ["foo"] ... >>> A.__slots__ ['foo']

[issue46247] in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__

2022-01-14 Thread Éric Araujo
Change by Éric Araujo : -- versions: -Python 3.7, Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46244] typing._TypeVarLike missing __slots__

2022-01-11 Thread Alex Waygood
Change by Alex Waygood : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed type: performance -> behavior ___ Python tracker ___

[issue46244] typing._TypeVarLike missing __slots__

2022-01-10 Thread Guido van Rossum
Guido van Rossum added the comment: Yes.-- --Guido (mobile) -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue46244] typing._TypeVarLike missing __slots__

2022-01-10 Thread Kumar Aditya
Kumar Aditya added the comment: Can this be closed now ? -- versions: -Python 3.10 ___ Python tracker ___ ___ Python-bugs-list

[issue46244] typing._TypeVarLike missing __slots__

2022-01-10 Thread Ken Jin
Ken Jin added the comment: New changeset 081a2140083680ffc309e53699aea29e71760d70 by Arie Bovenberg in branch 'main': bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec (#30444) https://github.com/python/cpython/commit/081a2140083680ffc309e53699aea29e71760d70

[issue46298] Automatically check for __slots__-mistakes in Lib

2022-01-07 Thread Arie Bovenberg
New submission from Arie Bovenberg : Recently, I've identified some __slots__-related mistakes in the stdlib (bpo-46247, bpo-46244, bpo-46246). Looking forward, it'd be wise to automate this check so mistakes don't creep into the code in the future. Implementation-wise, the most

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-07 Thread Arie Bovenberg
Change by Arie Bovenberg : -- keywords: +patch pull_requests: +28656 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30452 ___ Python tracker ___

[issue46244] typing._TypeVarLike missing __slots__

2022-01-06 Thread Arie Bovenberg
Change by Arie Bovenberg : -- keywords: +patch pull_requests: +28650 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30444 ___ Python tracker ___

[issue46244] typing._TypeVarLike missing __slots__

2022-01-06 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +AlexWaygood ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46244] typing._TypeVarLike missing __slots__

2022-01-06 Thread Kumar Aditya
Change by Kumar Aditya : -- nosy: +kumaraditya303 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46244] typing._TypeVarLike missing __slots__

2022-01-04 Thread Arie Bovenberg
Arie Bovenberg added the comment: @kj I would very much like to! Seems like a good place to start contributing :) -- ___ Python tracker ___

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-04 Thread Jason R. Coombs
Jason R. Coombs added the comment: Today I learned something. Thanks Arie. Yes, I agree that's a mistake. Perhaps the test suite should also have a test to capture the missed expectation (that __dict__ should not be present or setting attributes on EntryPoints instances should fail).

[issue46244] typing._TypeVarLike missing __slots__

2022-01-04 Thread Ken Jin
Ken Jin added the comment: Good catch Arie. Would you like to submit a PR for this? -- ___ Python tracker ___ ___ Python-bugs-list

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: @jaraco thanks for your quick response. In short: __slots__ allows class layout to be optimized by replacing the class __dict__ with specific descriptors. This results in a class where only specific attributes can be get/set. However, you only really get

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-03 Thread Jason R. Coombs
Jason R. Coombs added the comment: Perhaps it is a mistake. The `__slots__` were added as a (possible premature) optimization in [this conversation](https://github.com/python/importlib_metadata/pull/278/files#r565475347). It's not obvious to me what the danger is in defining __slots__

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-03 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +jaraco ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46247] in xml.dom.minidom, Node and DocumentLS appear to be missing __slots__

2022-01-03 Thread Arie Bovenberg
New submission from Arie Bovenberg : (as instructed in bpo-46244, I've created this ticket) The classes Node and DocumentLS don't define __slots__, but a number of subclasses do. This appears to be a mistake. If so, I'd like to create a PR to fix it. -- components: Library (Lib

[issue46246] importlib.metadata.DeprecatedList appears to be missing __slots__

2022-01-03 Thread Arie Bovenberg
New submission from Arie Bovenberg : (as instructed in bpo-46244, I've created this ticket) The subclass `EntryPoints` defines __slots__, but its base `DeprecatedList` does not. This appears to be a mistake. If so, I'd like to create a PR to fix it. -- components: Library (Lib

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: Thanks! I'll open new issues shortly on xml and importlib -- ___ Python tracker ___ ___

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Guido van Rossum
Guido van Rossum added the comment: Confirmed about _TypeVarLike. Go ahead and make a PR. Do add a news blurb when requested. Please open separate issues for other such classes, each fix may need to be reviewed by a different expert. -- ___

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +gvanrossum, kj ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: I've also encountered other classes in the stdlib possibly missing slots: - importlib.metadata.DeprecatedList (subclass EntryPoints has slots) - xml.dom.minidom.Node, xml.dom.xmlbuilder.DocumentLS (5 subclasses have slots) Will investigate. --

[issue46244] typing._TypeVarLike missing __slots__

2022-01-03 Thread Arie Bovenberg
New submission from Arie Bovenberg : The mixin class "typing._TypeVarLike" has no __slots__. Its subclasses do define __slots__, so it looks like a mistake. Agree? It should be an easy fix, and I'd like to pick this up. -- components: Library (Lib) messages: 4

[issue46132] Consider adding __slots__ to enums?

2021-12-19 Thread Ethan Furman
Ethan Furman added the comment: Some testing reveals that `__slots__` is not a good option for Enum -- it makes it impossible to mix in in other types such as `int`. -- ___ Python tracker <https://bugs.python.org/issue46

[issue46132] Consider adding __slots__ to enums?

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: > In which case: consider this a feature request to > consider adding __slots__ ... A few thoughts: * Enumerations tend to be small, so a space savings likely isn't relevant. * In Python 3.11, the speed advantage of slots is now much smaller. * Th

[issue46132] Consider adding __slots__ to enums?

2021-12-19 Thread Alex Waygood
Alex Waygood added the comment: Ah, of course, I'm an idiot — I forgot that a class could not prevent the creation of __dict__ unless the parent class also had __slots__. Thanks, Christian. In which case: consider this a feature request to consider adding __slots__ to enum.Enum: for faster

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Alex Waygood
Alex Waygood added the comment: Thanks for taking the time to review and merge :) -- ___ Python tracker ___ ___ Python-bugs-list

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 8bfb11a791679a33024c9857e082afed0d71e0b4 by Miss Islington (bot) in branch '3.9': bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) (GH-30207) https://github.com/python/cpython/commit

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset d7537ac8e3a3ef15d2c5f3fe90e998618b6a97b9 by Miss Islington (bot) in branch '3.10': bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) (GH-30206) https://github.com/python/cpython/commit

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks for the PR. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset aeb9ef4c7287fe367b6e9adcf1c5f994d5bc1a09 by Alex Waygood in branch 'main': bpo-46076: Improve documentation for per-attribute docstrings with `__slots__` (GH-30109) https://github.com/python/cpython/commit

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread miss-islington
Change by miss-islington : -- pull_requests: +28428 pull_request: https://github.com/python/cpython/pull/30207 ___ Python tracker ___

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-19 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 3.0 -> 4.0 pull_requests: +28427 pull_request: https://github.com/python/cpython/pull/30206 ___ Python tracker

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-14 Thread Alex Waygood
Change by Alex Waygood : -- keywords: +patch pull_requests: +28332 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30109 ___ Python tracker ___

[issue46076] Document using __slots__ to provide per-attribute docstrings

2021-12-14 Thread Alex Waygood
New submission from Alex Waygood : The ability to add docstrings for individual attributes, by using a dictionary for __slots__ was added in Issue36326. This is a fantastic feature, and deserves better documentation. It appears to currently only be documented in the "What's New&q

[issue22098] Behavior of Structure inconsistent with BigEndianStructure when using __slots__

2021-10-23 Thread Yoann Aubineau
Change by Yoann Aubineau : -- nosy: -yaubi ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-22 Thread Nikita Sobolev
Change by Nikita Sobolev : -- keywords: +patch nosy: +sobolevn nosy_count: 3.0 -> 4.0 pull_requests: +27423 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29147 ___ Python tracker

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-20 Thread Justin Furuness
Justin Furuness added the comment: Thank you for the in-depth explanation. That all makes sense to me, I have run into the __slots__ with defaults issues before, I'll be sure to try out these fixes. I appreciate you taking the time. Thanks, Justin On Tue, Oct 19, 2021 at 5:28 PM Josh

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-19 Thread Josh Rosenberg
Josh Rosenberg added the comment: You're right that in non-dataclass scenarios, you'd just use __slots__. The slots=True thing was necessary for any case where any of the dataclass's attributes have default values (my_int: int = 0), or are defined with fields (my_list: list = field

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-19 Thread Justin Furuness
Justin Furuness added the comment: I didn't realize it was possible to add slots in that way (slots=True). I think for normal classes manually defining __slots__ is the common way of adding __slots__ (at least for me), so it feels weird to me that manually defining __slots__ instead of adding

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-18 Thread Josh Rosenberg
Josh Rosenberg added the comment: When I define this with the new-in-3.10 slots=True argument to dataclass rather than manually defining __slots__ it works just fine. Looks like the pickle format changes rather dramatically to accommodate it. >>> @dataclass(frozen=True, s

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-18 Thread Filipe Laíns
Change by Filipe Laíns : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45520] Frozen dataclass deep copy doesn't work with __slots__

2021-10-18 Thread Christina Gorbenko
, this is the first time I've submitted an issue here so I'm not quite sure how to do it properly. Example below: ``` from dataclasses import dataclass from copy import deepcopy @dataclass(frozen=True) class FrozenData: # Without slots no errors occur? __slots__ = "my_string", my_s

[issue44655] Confusing error with __slots__

2021-07-16 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 2.0 -> 3.0 pull_requests: +25733 pull_request: https://github.com/python/cpython/pull/27198 ___ Python tracker

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 6714dec5e104bdee4a0ed4d9966de27d1bfa1e3d by Pablo Galindo Salgado in branch 'main': bpo-44655: Don't include suggestions for attributes that are the same as the missing one (GH-27197)

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
eption it was there. This difference is based on the attribute error for a slot not initialized vs an attribute error for something that is not there. For example, in 3.9: --- class E: __slots__=('blech') E().blech Traceback (most recent call last): File "/home/pablogsal/github/cpython/lel.py", l

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +25732 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27197 ___ Python tracker

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: Thanks, Pablo! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: It's obviously not super important, but it would be nicer if the version with the suggestion were more like the version without the suggestion. Specifically, mentioning the object type: >>> class E: ... __slots__=('a') ... >>> E()

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Maybe don't print the "Did you mean" part if the suggestion is the same as > the requested attribute? I think this is a good idea and will take care of many other similar cases. Thanks for the suggestion, Eric! I will prepare a PR --

[issue44655] Confusing error with __slots__

2021-07-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: For attribute errors we just call dir() on the object and we do a suggestion based on the names so if a name appears in the dir() then we will consider it for the suggestion. -- ___ Python tracker

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
Eric V. Smith added the comment: Also, the dot after the first 'b' was confusing to me: I thought it had something to do with an attribute of b. And the quotes around the second 'b' were also confusing, but that's mostly because the original example initialized a class variable named 'b'

[issue44655] Confusing error with __slots__

2021-07-16 Thread Eric V. Smith
New submission from Eric V. Smith : This is related to issue 44649. This is the simplest non-dataclasses case I could come up with. Given: class Example: __slots__ = ('a', 'b') def __init__(self, a): self.a = a obj = Example(42) print(obj.b) I get this in 3.10 and main

[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
(it has no __dict__, so the 56 is the total cost). Dropping overhead of the instances by >60% can make a difference if you're really making many thousands of them. Personally, I think Python level classes should generally default to using __slots__ unless the classes are explici

[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
it) I would like to reduce the memory footprint of these classes by using __slots__. The issue now becomes that asyncio.Semaphore (like most other asyncio classes) have not defined __slots__, this prohibits my subclass from taking advantage of __slots__

[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
eError: 'bytes' object has no attribute '__dict__' >>> [2.72, 3.14].__dict__ Traceback (most recent call last): File "", line 1, in AttributeError: 'list' object has no attribute '__dict__' > __slots__ allow us to explicitly declare data members (like properties) and > d

[issue44318] Asyncio classes missing __slots__

2021-06-05 Thread wyz23x2
Change by wyz23x2 : -- nosy: -wyz23x2 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[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 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

[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

[issue42269] Add ability to set __slots__ in dataclasses

2021-04-30 Thread Eric V. Smith
Eric V. Smith added the comment: Thanks for all of your work, Yurii. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

  1   2   3   4   5   6   >