@marcan42 I haven't tested it, but I think you can turn this into a one-liner:
i = a_dict.setdefault(i, i)
-
-
-
@mcpowr That sounds right, but given the subtlety I wanted to make sure I know exactly what happens. Note: I don't use a_dict elsewhere. - Show replies
New conversation -
-
-
@Achifaifa Nope. a_dict is initialized to an empty dict and not used anywhere else in the code.Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
@marcan42 Integer caching a la CPython on some other interpreter? -
.
@saghul You got it, except this is in fact CPython, and CPython does _not_ cache (non-small) integers! That's the problem I was solving. - Show replies
New conversation -
-
-
@marcan42 Does the code trick python into keeping a reference to i?Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.