Steven D'Aprano added the comment:

Can confirm the expected behaviour (printing True) in Python 2.4 through 2.7, 
3.3, Jython 2.5, and even venerable old Python 1.5 (where it prints 1).

But *not* IronPython 2.6, where it prints False.

In 3.6, the difference seems to be here:

py> f = defaultKeepsIdentity
py> f.__defaults__[0] is f.__code__.co_consts[1]
False
py> f.__defaults__[0] == f.__code__.co_consts[1]
True

This behaviour is not specified by the language. Caching and re-use of strings 
has always been subject to change. Nevertheless, perhaps it is time for this to 
be make a language feature: inside a function, any use of the same string 
literal should use the same object?

----------
nosy: +steven.daprano

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

Reply via email to