Data structures in Python

Source: Internet
Author: User

Variables store the data in memory. This means that there is a space in memory when creating variables. Based on the data type of the variable, the interpreter allocates the specified memory and determines what data can be stored in memory.

Variables in Python do not need to be declared , and the assignment of variables is the process of declaring and defining variables. Therefore, each variable must be assigned before it is used, and the variable will not be created until the variable is assigned.

The data structures in Python mainly include: sequences (such as lists, Ganso, strings), mappings (such as dictionaries), collections.

where Ganso and strings in the sequence are immutable types. Reason, official explanation:

One is performance:knowing this a string is immutable means we can allocate space for it at creation time, and the Storag E Requirements is fixed and unchanging. This was also one of the reasons for the distinction between tuples and lists.

Another advantage is this strings in Python is considered as "elemental" as numbers. No amount of activity would change the value 8 to anything else, and in Python, no amount of activity would change the Strin G "Eight" to anything else.

That is: The first one is better performance, at the time of the creation of the allocation of fixed-size memory, the second is the string, the number is the basic type, relative to other data types, the situation is less changed.

Data structures in Python

Related Article

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.