================================================================================DOMAIN_URL: docs.python.org PAGE_URL: https://docs.python.org/3.7/reference/datamodel.html TITLE: 3. Data model — Python 3.7.17 documentation CRAWLED: 2026-06-07T21:58:43Z CATEGORY: technology RELEVANCE_SCORE: 83.00 WORD_COUNT: 12601 KEYWORDS: objects, object, value, type, numbers, python, implementation, immutable, garbage, point, values, change, types, built, single IMAGES (2): - URL: https://docs.python.org/3.7/_static/py.png - URL: https://docs.python.org/3.7/_static/py.png INTERNAL_LINKS (50): - https://docs.python.org/3/reference/datamodel.html - https://docs.python.org/3.7/genindex.html - https://docs.python.org/3.7/py-modindex.html - https://docs.python.org/3.7/reference/executionmodel.html - https://docs.python.org/3.7/reference/lexical_analysis.html - https://python.org/ - https://docs.python.org/3.7/index.html - https://docs.python.org/3.7/reference/index.html - https://docs.python.org/3.7/reference/expressions.html - https://docs.python.org/3.7/library/functions.html - https://docs.python.org/3.7/library/functions.html - https://docs.python.org/3.7/library/gc.html - https://docs.python.org/3.7/reference/compound_stmts.html - https://docs.python.org/3.7/reference/compound_stmts.html - https://docs.python.org/3.7/reference/compound_stmts.html - https://docs.python.org/3.7/reference/compound_stmts.html - https://docs.python.org/3.7/reference/compound_stmts.html - https://docs.python.org/3.7/library/numbers.html - https://docs.python.org/3.7/library/numbers.html - https://docs.python.org/3.7/library/numbers.html EXTERNAL_LINKS (3): - http://ocert.org/advisories/ocert-2011-003.html - https://github.com/python/cpython/blob/3.7/Doc/reference/datamodel.rst - http://sphinx.pocoo.org/ METADATA: - generator: Docutils 0.17.1: http://docutils.sourceforge.net/ CONTENT: EnglishSpanish | españolFrench | françaisItalian | italianoJapanese | 日本語Korean | 한국어Polish | polskiBrazilian Portuguese | Português brasileiroTurkish | TürkçeSimplified Chinese | 简体中文Traditional Chinese | 繁體中文dev (3.14)3.133.123.113.103.93.83.7.173.63.53.43.33.23.13.02.72.6 Objectsare Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. (In a sense, and in conformance to Von Neumann’s model of a “stored program computer”, code is also represented by objects.) Every object has an identity, a type and a value. An object’sidentitynever changes once it has been created; you may think of it as the object’s address in memory. The ‘is’ operator compares the identity of two objects; theid()function returns an integer representing its identity. CPython implementation detail:For CPython,id(x)is the memory address wherexis stored. An object’s type determines the operations that the object supports (e.g., “does it have a length?”) and also defines the possible values for objects of that type. Thetype()function returns an object’s type (which is an object itself). Like its identity, an object’stypeis also unchangeable.1 Thevalueof some objects can change. Objects whose value can change are said to bemutable; objects whose value is unchangeable once they are created are calledimmutable. (The value of an immutable container object that contains a reference to a mutable object can change when the latter’s value is changed; however the container is still considered immutable, because the collection of objects it contains cannot be changed. So, immutability is not strictly the same as having an unchangeable value, it is more subtle.) An object’s mutability is determined by its type; for instance, numbers, strings and tuples are immutable, while dictionaries and lists are mutable. Objects are never explicitly destroyed; however, when they become unreachable they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether — it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that are still reachable. CPython implementation detail:CPython currently uses a reference-counting scheme with (optional) delayed detection of cyclically linked garbage, which collects most objects as soon as they become unreachable, but is not guaranteed to collect garbage containing circular references. See the documentation of thegcmodule for information on controlling the collection of cyclic garbage. Other implementations act differently and CPython may change. Do not depend on immediate finalization of objects when they become unreachable (so you should always close files explicitly). Note that the use of the implementation’s tracing or debugging facilities may keep objects alive that would normally be collectable. Also note that catching an exception with a ‘try…except’ statement may keep object ================================================================================