Quick question about CPython interpreter

Chris Angelico rosuav at gmail.com
Mon Oct 17 13:59:05 EDT 2022


On Tue, 18 Oct 2022 at 03:51, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>
> MRAB <python at mrabarnett.plus.com> writes:
> >It can't optimise that because, say, 'print' could've been bound to a
> >function that rebinds 'str'.
>
>   It would be possible to find out whether a call of a function
>   named "print" is to the standard function, but the overhead
>   to do this in the end might slow down the execution.
>
>   In general, it can be possible that there could be optimizer
>   stages after compilation. So, one might write a small micro-
>   benchmark to be sure.
>

You'd also have to ensure that the stringification of the ID doesn't
change (which it can it it isn't a core data type), and the easiest
way to do THAT is to call str() on the ID every time and see if it's
the same...

ChrisA


More information about the Python-list mailing list