STINNER Victor added the comment:
+ int_pool = {i: i for i in range(-1000, 1000)}
+ def get_pooled_int(v):
+ return int_pool.setdefault(v, v)
I'm not sure that I understand this code. It makes sure that you get a single
object in memory for the same integer, and not only for Python "small integer
singletons"?
About the -1000..1000 range: if a function leaks more than 1 memory block or
more than 1 reference, there is already something wrong no?
Maybe it's ok to only care of values -1, 0 and 1 :-) My code only cares of
Python small integer singletons.
I have no strong preference between my code or yours. I only care of fixing the
buildbot :-) What do you prefer, Antoine?
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue31217>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com