[issue23726] Don't enable GC for classes that don't add new fields
Eugene Toder added the comment: Thank you! Benjamin, Nathaniel, any opinion if we should restrict reassigning __class__ for types like tuple, int and str, where some/many instances are cached? -- nosy: +njs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Roundup Robot added the comment: New changeset a60b7945ef87 by Antoine Pitrou in branch 'default': Issue #23726: Don't enable GC for user subclasses of non-GC types that don't add any new fields. https://hg.python.org/cpython/rev/a60b7945ef87 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Eugene Toder added the comment: Agreed. There's a small problem with that, as far as I know. Nothing on type declares that it is immutable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Nathaniel Smith added the comment: Yes, it probably would be a good idea to disallow assigning __class__ for immutable types. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Antoine Pitrou added the comment: I've pushed the patch, thank you! -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Changes by Eugene Toder elto...@gmail.com: Added file: http://bugs.python.org/file38624/class_gc2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
New submission from Eugene Toder: As far as I can tell, if a new class does not add any new fields, and its base class doesn't use GC, there's no reason to enable GC for the new class. This is useful for creating lightweight wrappers around classes implemented in C. -- files: class_gc.diff keywords: patch messages: 238718 nosy: eltoder, pitrou priority: normal severity: normal status: open title: Don't enable GC for classes that don't add new fields type: performance versions: Python 3.6 Added file: http://bugs.python.org/file38610/class_gc.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Changes by Serhiy Storchaka storch...@gmail.com: -- components: +Interpreter Core nosy: +serhiy.storchaka stage: - patch review versions: +Python 3.5 -Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Serhiy Storchaka added the comment: class UserIntSlots(int): ... __slots__ = () ... def __repr__(s): return '5' ... (4).__class__ = UserIntSlots 2+2 5 type(2+2) class '__main__.UserIntSlots' It looks weird. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Eugene Toder added the comment: Agreed, but this is not new. This works without my change: class Tuple(tuple): ... __slots__ = () ... def __repr__(self): return 'Imma tuple!' ... ().__class__ = Tuple () Imma tuple! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Antoine Pitrou added the comment: I wasn't aware of that :-o -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Serhiy Storchaka added the comment: May be we should forbid assigning the __class__ attribute of basic builtin types (especially internable, such as int, str, bytes, tuple, bool, NoneType). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Eugene Toder added the comment: Actually, this is rather new -- new in 3.5. The check was relaxed in #22986: https://hg.python.org/cpython/rev/c0d25de5919e Previously only heap types allowed re-assigning __class__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23726] Don't enable GC for classes that don't add new fields
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23726 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com