[Python-Dev] Wordcode: new regular bytecode using 16-bit units (original) (raw)

Victor Stinner 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 = 1nonArgumentOps + 3oneByteArgs + 3*multiByteArgs wordCodeSize = 2nonArgumentOps + 2oneByteArgs + 4*multiByteArgs

If multiByteArgs means any size > 1 byte, the wordCodeSize formula is wrong:

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 EXTENDEDARG operator in the wild, only in my own synthetic examples.)

As I wrote, EXTENDED_ARG can be seen when MAKE_FUNCTION is used with annotations.

Victor



More information about the Python-Dev mailing list