Cómo funciona la memoria en Python

¿Qué es la memoria y por qué se necesita?

. , , . ? , «» , , - 16Gb DDR4 2666MHz. , , — , , , . , , ( ) .





-, , () , SWAP- .





-, , , «», , , . « », , 4 RAM ( 32- ) ( 64-).





, , . , ? :





  1. () ( ) .





  2. .





  3. .





. , , , .. .. . — . — . - , : , .





, . , , runtime . , , .





Python

Python — . . . , Python’ CPython, - , - :)





Python- , , . Python , .





Python’. CPython , . , .





. — , .., . . , Python . — , .. Python — .





. ( 512 ) Python . , . RAM .





? :





  • — ( 256 ), .





  • — ( 4 ).





  • , .





. Python’ - . , . «»? . . ? . — , Python. - , . , , .





. ( , ).





— used, full empty. Full , . Empty — ( ). Used — , , .





Python . , Python used- . used- , empty-, ( empty used). empty- , .





. . . 8, 16, 24, 32 …. 512 . 44 , 48 . ( , untouched-, , free-, ). , , . , .





GIL

, Python, , . Python :





  • .





  • .





Python — , , , PyObject. PyObject : ob_refcnt



— , ob_type



— , .





ob_refcnt



. . , , .. ( - ), . , , .. ( ), . 0 — Python ( , , ).





, . . CPython GIL — Global Interpreter Lock. , , GIL — — . , , .





— (garbage collector), . , ? , , A B, B — A. , A B, . ( gc, Python 1.5).





: GC (-, ) , Python. , . — .





, . . GC . . , . , . . : , . , , .





. . , , Python , . , Python . 





Python. , , .





?

:





  • .





  • , Python .





  • Memory Mapping.





  • .





:)








All Articles