Message301082
| Author |
vstinner |
| Recipients |
brett.cannon, pitrou, vstinner, zach.ware |
| Date |
2017年09月01日.00:58:58 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1504227538.45.0.559234534715.issue31217@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
+ 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? |
|
History
|
|---|
| 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 |
|