Message301082
+ 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? |
|
Date |
User |
Action |
Args |
2017-09-01 00:58:58 | vstinner | set | recipients:
+ vstinner, brett.cannon, pitrou, zach.ware |
2017-09-01 00:58:58 | vstinner | set | messageid: <1504227538.45.0.559234534715.issue31217@psf.upfronthosting.co.za> |
2017-09-01 00:58:58 | vstinner | link | issue31217 messages |
2017-09-01 00:58:58 | vstinner | create | |
|