[issue23726] Don't enable GC for classes that don't add new fields

2015-04-13 Thread Eugene Toder

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 

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

2015-04-13 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Yes, it probably would be a good idea to disallow assigning __class__ for 
immutable types.

--

___
Python tracker 

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

2015-04-13 Thread Eugene Toder

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 

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

2015-04-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I've pushed the patch, thank you!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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

2015-04-13 Thread Roundup Robot

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 

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

2015-03-21 Thread Eugene Toder

Changes by Eugene Toder :


Added file: http://bugs.python.org/file38624/class_gc2.diff

___
Python tracker 

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

2015-03-20 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +benjamin.peterson

___
Python tracker 

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

2015-03-20 Thread Eugene Toder

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 

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

2015-03-20 Thread Serhiy Storchaka

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 

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

2015-03-20 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I wasn't aware of that :-o

--

___
Python tracker 

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

2015-03-20 Thread Eugene Toder

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 

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

2015-03-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

>>> class UserIntSlots(int):
... __slots__ = ()
... def __repr__(s): return '5'
... 
>>> (4).__class__ = UserIntSlots
>>> 2+2
5
>>> type(2+2)


It looks weird.

--

___
Python tracker 

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

2015-03-20 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Interpreter Core
nosy: +serhiy.storchaka
stage:  -> patch review
versions: +Python 3.5 -Python 3.6

___
Python tracker 

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

2015-03-20 Thread Eugene Toder

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com