Comments (4)
第一个问题应该是由于 Python 从 3.7 开始不再使用 peephole optimization
, 而是使用新的 AST Optimizer 技术。
博客中的这个问题也是在Python3.6时代提出的,3.7 应该是也修改了实现方式。
from wtfpython-cn.
'wtf'的例子,这不是3个字符吗?为什么解释里说是 0个或1个才字符驻存?
from wtfpython-cn.
'wtf'的例子,这不是3个字符吗?为什么解释里说是 0个或1个才字符驻存?
不是长度为0或1的“才”驻留,而是长度为0或1的字符串“都”驻留。比如,如果长度大于1 的的字符串中如果包含!
就不会被驻留,但是字符串是只有一个!
的长度为1的字符串,就会被驻留。
from wtfpython-cn.
a='wtf!' b='wtf!' print(a is b) c,d='wtf!','wtf!' print(c is d)
我得到的结果均为True(python3.9.6)
from wtfpython-cn.
Related Issues (20)
- Class attributes and instance attributes/类属性和实例属性 HOT 2
- Subclass relationships/子类关系 * 的翻译 HOT 1
- is is not what it is!/出人意料的is! HOT 1
- is is not what it is!/出人意料的is! 单行赋值,交互式环境执行的版本问题
- 一个未配对的括号 HOT 1
- windows 10 运行 wtfpython 报错 HOT 1
- 333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 HOT 2
- 3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 HOT 2
- MacOS pip3.6 安装wtfpython, run wtfpython后报错FileNotFoundError
- A tic-tac-toe where X wins in the first attempt!/一蹴即至! HOT 1
- Section: Strings can be tricky sometimes/微妙的字符串 * 中常量折叠在3.7中已经迁移至新的AST 优化器 HOT 1
- >>> 0.4-0.3 结果为啥是 0.10000000000000003 HOT 4
- 字符串缓存中注释存在错误? HOT 5
- Sync with English version HOT 2
- About Evaluation time discrepancy/执行时机差异 HOT 3
- 对/=运算符的疑惑 HOT 4
- 一个错别字... HOT 3
- Beware of default mutable arguments!/当心默认的可变参数!
- 中文版本的更新问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wtfpython-cn.