Understanding variable types, names and assignment
<p>In Python, if you want to define a  variable, you don't have to specify the type of it, unlike other languages such as C and Java.</p>

<p>So how can the Python interpreter distinguish between variables and give it the required space in memory like <code>int</code> or <code>float</code>?</p>

<p>Dynamically typed languages typically use boxed representation, which includes runtime type information. E.g. instead of storing direct pointers to a value, the system uses a box struct that contains the value (or pointer to it) as well as some additional metainformation.  You can see how he standard Python implementation does it here: <a href="https://github.com/python/cpython/blob/master/Include/object.h">https://github.com/python/cpython/blob/master/Include/object.h</a></p>

<p>There are some interesting tricks that can be employed here. For instance, one technique is value tagging, where the type description is stored as part of the value itself, utilising unused bytes. For instance, pointers on current x86-64 CPUs can't utilise the full address space, which gives you some bits to play with. Another variant of this technique is NaN-tagging (I believe this was first used by Mike Pall, author of LuaJIT) - where all values are stored as doubles, and various NaN states of the value signal that it is actually a pointer or some other type of data. </p>

python