diff --git a/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb b/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb index 976101b..aea454a 100644 --- a/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb +++ b/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:161acdaa5124ca9e1082a3b0564e8792f64364ea91cd2cff096fdbbff37408ca" + "signature": "sha256:e20426bb66111696c7ec4f8d754946061e129b3e332a6cc2fd00331b9540d8c5" }, "nbformat": 3, "nbformat_minor": 0, @@ -212,7 +212,9 @@ "\n", "## Python reuses objects for small integers - always use \"==\" for equality, \"is\" for identity\n", "\n", - "This oddity occurs, because Python tends to stores small integers as the same object, but not so for larger ones! \n", + "This oddity occurs, because Python keeps an array of small integer objects (i.e., integers between -5 and 256, [see the doc](https://docs.python.org/2/c-api/int.html#PyInt_FromLong)).\n", + "\n", + "\n", "(*I received a comment that this is in fact a CPython artefact and must not necessarily be true in all implementations of Python!*)\n", "\n", "So the take home message is: always use \"==\" for equality, \"is\" for identity!\n", diff --git a/not_so_obvious_python_stuff.ipynb b/not_so_obvious_python_stuff.ipynb index 976101b..aea454a 100644 --- a/not_so_obvious_python_stuff.ipynb +++ b/not_so_obvious_python_stuff.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:161acdaa5124ca9e1082a3b0564e8792f64364ea91cd2cff096fdbbff37408ca" + "signature": "sha256:e20426bb66111696c7ec4f8d754946061e129b3e332a6cc2fd00331b9540d8c5" }, "nbformat": 3, "nbformat_minor": 0, @@ -212,7 +212,9 @@ "\n", "## Python reuses objects for small integers - always use \"==\" for equality, \"is\" for identity\n", "\n", - "This oddity occurs, because Python tends to stores small integers as the same object, but not so for larger ones! \n", + "This oddity occurs, because Python keeps an array of small integer objects (i.e., integers between -5 and 256, [see the doc](https://docs.python.org/2/c-api/int.html#PyInt_FromLong)).\n", + "\n", + "\n", "(*I received a comment that this is in fact a CPython artefact and must not necessarily be true in all implementations of Python!*)\n", "\n", "So the take home message is: always use \"==\" for equality, \"is\" for identity!\n",