What is the difference between the Python idle explanation and the direct Python script.py explanation?

Source: Internet
Author: User

Reply content:

The idea of the difference between "row by line" and "whole interpretation" is right, but the details are not. Here are some details.
It doesn't matter with sublime and idle.

$ pythonPython 2.7.5 (default, Mar  9  the,  A: the: to) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0. the)]  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 the identity, if the two variable ID (address) is the same, then A is B is true;
So from the implementation of the results, it is also consistent.

As for the difference in the question, that is to achieve the relevant, like 10.1 such small Whether number is re-assigned will reuse the ID that is implementation related (my 2.7.6 is a different ID), and I estimate that sublime itself has a Python runtime (not quite sure, I don't use sublime), so there will be different performance. Bury yourself a hole, today suddenly think of a possibility, because idle is an explanation of the command, and Python floating point in the heap memory, each time a floating-point number is created, the heap memory address will be directly stacked, when creating the same floating point, idle will also perform repetitive actions, and when written to the script, When executed with an interpreter, a simple numeric object is checked to see if the object is already present (the value object is more simple to repeat), so that the existing heap address can be stacked directly.
It should be the Python interpreter existence W said the runtime, how to see the interpreter after the implementation process to understand. Wait for pits later.
  • 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.