Chapter II python basic data types

Source: Internet
Author: User

variables and identity operations

ID () Definition: The function is used to get the memory address of the object.

To name a list:

name = ' Tangni '
ID (name)

Output
(56156880)

1.1 Two variable names one value column:

Since ' Tangni ' is a simple string, the Python interpreter has been optimized, with only one ' Tangni ' in memory, name1 and name2 all pointing to the same memory address.

name1 = ' Tangni '
name2 = ' Tangni '
name1_id = ID (name1)
name2_id = ID (name2)
Print (name1_id,name2_id)

Output
(56156880 56156880)

1.2 If it is a long string there is no optimization mechanism!

>>> a =  ' This is a very long sentence ' >>> b =  ' This is a very long sentence ' >>> id (A4394464720>>> id4394464640 
1.3 column in the range:

A = 256
b = 256
ID (a)
1502186480
ID (b)
1502186480

Beyond the range:

A = 257

b = 257

ID (a)
55420240
ID (b)
55419312

Identity operations





Chapter II python basic data types

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.