What is the difference between pythonidle and pythonscript. py?

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply: The difference between the subject's line-by-line explanation and the overall explanation is correct, but the details are not quite correct. The following describes the details.
It has nothing to do with Sublime and IDLE.

$ pythonPython 2.7.5 (default, Mar  9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> a = 10.1>>> b = 10.1>>> a is bFalse>>> id(a)140475784803760>>> id(b)140475784803736>>> (10.1) is (10.1)True>>> def foo():...   a = 10.1...   b = 10.1...   return a is b... >>> foo()True
IsIs used to determine identity. if the two variables have the same id (address), a is B is True;
Therefore, the execution results are also consistent.

As for the difference in the problem, it is implementation-related. whether small numbers such as 10.1 are re-assigned will reuse the id, which is implementation-related (my 2.7.6 is different id ); I guess the sublime itself may have built-in python Runtime (not sure, I don't use sublime much), so it will show different performances. Today, I suddenly think of a possibility that IDLE explains commands one by one, while the floating point in python is stored in the heap memory. each time I create a floating point, the heap memory address is directly pushed to the stack. when the same floating point number is created, the IDLE also performs repeated actions. when writing to the script and executing it with the interpreter, it encounters a simple numeric object, the system checks whether the object already exists (it is relatively simple to repeat the value object), so that the existing heap address can be directly pressed to the stack.
It should be because the interpreter of python exists in the runtime that Zhu Tao said. after reading the implementation process of the interpreter, I can see how to understand it. .

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.