Two aces up Python's sleeve

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 7 17:15:38 EST 2024


On 8/11/24 3:04 am, Mild Shock wrote:
> This only works for small integers. I guess
> this is because tagged pointers are used
> nowadays ?

No, it's because integers in a certain small range are cached. Not sure 
what the actual range is nowadays, it used to be something like -5 to 
256 I think.

BTW you have to be careful testing this, because the compiler sometimes 
does constant folding, so you need to be sure it's actually computing 
the numbers at run time.

-- 
Greg


More information about the Python-list mailing list