miniblog.
← Back to all posts
Sep 24, 2014 at 21:59
Discovered that for integers in Python, hash(x) == x (most of the time). Seems elegant, but I was not expecting it!
Wilfred Hughes
Related Posts
Dec 1, 2017 at 20:08
Whilst Java's ArrayList overallocates by 50%:
https://stackoverflow.com/a/14129344/509706
I'm surprised to learn that Python only overallocates lists by ~12.5%:
https://github.com/python/cpython/blob/3.6/Objects/listobject.c#L49
I was not expecting such a range of values!
java - ArrayList: how does the size increase? - Stack Overflow
cpython/Objects/listobject.c at 3.6 · python/cpython
The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
Wilfred Hughes
Shared words: expecting, Python, not Score: 57.6
Sep 17, 2013 at 11:26
Surprised to discover that 'foo " bar' and 'foo \" bar" are the same in Python. Not what I was expecting.
Wilfred Hughes
Shared words: expecting, Python, not Score: 57.6
Apr 7, 2014 at 13:08
Obscure #python of the day: you can call methods on integers with a space. For example, `1 .__hash__()`
Wilfred Hughes
Shared words: integers, Python, hash Score: 43.9