Mark Shannon <m...@hotpy.org> added the comment:

Antoine Pitrou wrote:
> Antoine Pitrou <pit...@free.fr> added the comment:
> 
>> I have added a call to PyType_Modified in type_clear (as well as
>> type_set_name and type_set_qualname, which also modify the type).
> 
> Can __name__ and __qualname__ be looked up through the method cache?

__name__ and __qualname__ are not looked up through the method cache,
but their descriptors could be.
Changing the descriptors would be caught elsewhere,
so there is no need to to add any PyType_Modified to
type_set_name and type_set_qualname.

However, calls to PyType_Modified will never cause any errors,
and if only used for genuine type modifications, will cause no 
discernible performance degradation.

Since PyType_Modified is generally called whenever a type is modified, 
it is likely to act as a guardian for any future optimisations that 
require classes to be unchanged.

Thus, given these two reasons, it seems wise to call PyType_Modified 
anywhere the type is modified, however minor that modification appears 
to be.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12149>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to