Code Monkey home page Code Monkey logo

Comments (4)

leisurelicht avatar leisurelicht commented on September 7, 2024

第一个问题应该是由于 Python 从 3.7 开始不再使用 peephole optimization , 而是使用新的 AST Optimizer 技术。

博客中的这个问题也是在Python3.6时代提出的,3.7 应该是也修改了实现方式。

from wtfpython-cn.

kangkang59812 avatar kangkang59812 commented on September 7, 2024

'wtf'的例子,这不是3个字符吗?为什么解释里说是 0个或1个才字符驻存?

from wtfpython-cn.

leisurelicht avatar leisurelicht commented on September 7, 2024

'wtf'的例子,这不是3个字符吗?为什么解释里说是 0个或1个才字符驻存?

不是长度为0或1的“才”驻留,而是长度为0或1的字符串“都”驻留。比如,如果长度大于1 的的字符串中如果包含就不会被驻留,但是字符串是只有一个的长度为1的字符串,就会被驻留。

from wtfpython-cn.

S-N-O-R-L-A-X avatar S-N-O-R-L-A-X commented on September 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.