a is b oddity explained

This commit is contained in:
rasbt 2014-04-15 14:18:42 -04:00
parent 96f7d72972
commit ff938c4ac7
2 changed files with 15 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:437ca0df14a08cf4fd584f91122010286928f287ae14c5ac1ce8230abe9dbf9a" "signature": "sha256:43a74f5daf674621e35388775c4372dd9587ddf80df1e26c2c8301ae66424581"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -13,7 +13,9 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"Sebastian Raschka \n", "Sebastian Raschka \n",
"last updated: 04/15/2014" "last updated: 04/15/2014\n",
"\n",
"[Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb)"
] ]
}, },
{ {
@ -38,7 +40,7 @@
"- [The C3 class resolution algorithm for multiple class inheritance](#c3_class_res)\n", "- [The C3 class resolution algorithm for multiple class inheritance](#c3_class_res)\n",
"- [The behavior of += for lists](#pm_in_lists)\n", "- [The behavior of += for lists](#pm_in_lists)\n",
"- [`True` and `False` in the datetime module](#datetime_module)\n", "- [`True` and `False` in the datetime module](#datetime_module)\n",
"- [Some Python Oddity that I cannot explain, yet](#python_oddity)\n", "- [Python reuses objects for small integers](#python_small_int)\n",
"- [Shallow vs. deep copies if list contains other structures and objects](#shallow_vs_deep)\n", "- [Shallow vs. deep copies if list contains other structures and objects](#shallow_vs_deep)\n",
"- [Picking True values from and and or expressions](#false_true_expressions)" "- [Picking True values from and and or expressions](#false_true_expressions)"
] ]
@ -186,8 +188,10 @@
"source": [ "source": [
"<br>\n", "<br>\n",
"<br>\n", "<br>\n",
"<a name='python_oddity'></a>\n", "<a name='python_small_int'></a>\n",
"## Some Python Oddity that I cannot explain, yet" "## Python reuses objects for small integers \n",
"\n",
"This oddity occurs, because Python tends to stores small integers as the same object, but not so for larger ones!"
] ]
}, },
{ {

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:466467169d92398c710c1b7969b363ee4c4d32dcf96afa519dd8fb9162785cc4" "signature": "sha256:43a74f5daf674621e35388775c4372dd9587ddf80df1e26c2c8301ae66424581"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -40,7 +40,7 @@
"- [The C3 class resolution algorithm for multiple class inheritance](#c3_class_res)\n", "- [The C3 class resolution algorithm for multiple class inheritance](#c3_class_res)\n",
"- [The behavior of += for lists](#pm_in_lists)\n", "- [The behavior of += for lists](#pm_in_lists)\n",
"- [`True` and `False` in the datetime module](#datetime_module)\n", "- [`True` and `False` in the datetime module](#datetime_module)\n",
"- [Some Python Oddity that I cannot explain, yet](#python_oddity)\n", "- [Python reuses objects for small integers](#python_small_int)\n",
"- [Shallow vs. deep copies if list contains other structures and objects](#shallow_vs_deep)\n", "- [Shallow vs. deep copies if list contains other structures and objects](#shallow_vs_deep)\n",
"- [Picking True values from and and or expressions](#false_true_expressions)" "- [Picking True values from and and or expressions](#false_true_expressions)"
] ]
@ -188,8 +188,10 @@
"source": [ "source": [
"<br>\n", "<br>\n",
"<br>\n", "<br>\n",
"<a name='python_oddity'></a>\n", "<a name='python_small_int'></a>\n",
"## Some Python Oddity that I cannot explain, yet" "## Python reuses objects for small integers \n",
"\n",
"This oddity occurs, because Python tends to stores small integers as the same object, but not so for larger ones!"
] ]
}, },
{ {