[Python-Dev] Wordcode: new regular bytecode using 16-bit units
victor.stinner at gmail.com
Wed Apr 13 17:23:59 EDT 2016
2016-04-13 23:02 GMT+02:00 Eric Fahlgren <ericfahlgren at gmail.com>:
> Percentage of 1-byte args = 96.80%
Yeah, I expected such high ratio. Good news that you confirm it.
> Non-argument ops = 53,719
> One-byte args = 368,787
> Multi-byte args = 12,191
Again, only a very few arguments take multiple bytes. Good, the
bytecode will be smaller.
IMHO it's more a nice side effect than a real goal. The runtime
performance matters more than the size of the bytecode, it's not like
a bytecode take 4 MB. It's probably closer to 1 KB and so can probably
benefit of the fatest CPU caches.
> Just for the record, here's my arithmetic:
> byteCodeSize = 1*nonArgumentOps + 3*oneByteArgs + 3*multiByteArgs
> wordCodeSize = 2*nonArgumentOps + 2*oneByteArgs + 4*multiByteArgs
If multiByteArgs means any size > 1 byte, the wordCodeSize formula is wrong:
- no parameter: 2 bytes
- 8-bit parameter: 2 bytes
- 16-bit parameter: 4 bytes
- 24-bit parameter: 6 bytes
- 32-bit parameter: 8 bytes
But you wrote that you didn't see EXTEND_ARG, so I guess that
multibyte means 16-bit in your case, and so your formula is correct.
Hopefully, I don't expect 32-bit parameters in the wild, only 24-bit
parameter for function with annotation.
> (It is interesting to note that I have never encountered an EXTENDED_ARG operator in the wild, only in my own synthetic examples.)
As I wrote, EXTENDED_ARG can be seen when MAKE_FUNCTION is used with
More information about the Python-Dev