[Tutor] Python Memory Allocation -- deep learning
max at zettlmeissl.de
Mon Jul 30 09:38:35 EDT 2018
On Mon, Jul 30, 2018 at 3:20 PM, Sunil Tech <sunil.techspk at gmail.com> wrote:
> Python memory allocation is varying in all these use cases. Please help me
CPython is interning small integers and small strings as a form of optimisation.
"The current implementation keeps an array of integer objects for all
integers between -5 and 256, when you create an int in that range you
actually just get back a reference to the existing object."
For integers see https://docs.python.org/2/c-api/int.html for Python 2
or https://docs.python.org/3/c-api/long.html for Python 3.
For strings see https://hg.python.org/cpython/file/3.5/Objects/codeobject.c#l51
More information about the Tutor