Message274262
| Author |
steven.daprano |
| Recipients |
Kay.Hayen, steven.daprano |
| Date |
2016年09月02日.17:19:50 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1472836790.28.0.751403597074.issue27942@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年09月02日 17:19:50 | steven.daprano | set | recipients:
+ steven.daprano, Kay.Hayen |
| 2016年09月02日 17:19:50 | steven.daprano | set | messageid: <1472836790.28.0.751403597074.issue27942@psf.upfronthosting.co.za> |
| 2016年09月02日 17:19:50 | steven.daprano | link | issue27942 messages |
| 2016年09月02日 17:19:50 | steven.daprano | create |
|