[Python-Dev] Opcode cache in ceval loop

Yury Selivanov yselivanov.ml at gmail.com
Mon Feb 1 17:22:46 EST 2016



On 2016-02-01 4:21 PM, Yury Selivanov wrote:
> Hi Damien,
>
> On 2016-02-01 3:59 PM, Damien George wrote:
>
[..]
>>
>> But then how do you index the cache, do you keep a count of the
>> current opcode number?  If I remember correctly, CPython has some
>> opcodes taking 1 byte, and some taking 3 bytes, so the offset into the
>> bytecode cannot be easily mapped to a bytecode number.
>

Here are a few links that might explain the idea better:

https://github.com/1st1/cpython/blob/opcache5/Python/ceval.c#L1229
https://github.com/1st1/cpython/blob/opcache5/Python/ceval.c#L2610
https://github.com/1st1/cpython/blob/opcache5/Objects/codeobject.c#L167

Yury


More information about the Python-Dev mailing list