Python string with space and without space at the end and immutability
I learnt that in some immutable classes, __new__ may return an existing instance – this is what the int, str and tuple types sometimes do for small values.
I learnt that in some immutable classes, __new__ may return an existing instance – this is what the int, str and tuple types sometimes do for small values.
I’ve been trying to learn how CPython is implemented under the scenes. It’s great that Python is high level, but I don’t like treating it like a black box.
I would like a function that can generate a pseudo-random sequence of values, but for that sequence to be repeatable every run. The data I want has to be reasonably well randomly distributed over a given range, it doesn’t have to be perfect.
I was surprised to discover recently that while dicts are guaranteed to preserve insertion order in Python 3.7+, sets are not:
The best way to explain my question is with an example: