[Python-Dev] Wordcode: new regular bytecode using 16-bit units (original) (raw)
Eric Fahlgren ericfahlgren at gmail.com
Wed Apr 13 17:35:27 EDT 2016
- Previous message (by thread): [Python-Dev] Wordcode: new regular bytecode using 16-bit units
- Next message (by thread): [Python-Dev] Wordcode: new regular bytecode using 16-bit units
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The EXTENDED_ARG is included in the multibyte ops, I treat it just like any other operator. Here's a snippet of my hacked-dis.dis output, which made it clear to me that I could just count them as an "operator with word operand."
Line 3000: x = x if x or not x and x is None else x 0001dc83 7c 00 00 LOAD_FAST x 0001dc86 91 01 00 EXTENDED_ARG 1 0001dc89 70 9f dc JUMP_IF_TRUE_OR_POP L1dc9f 0001dc8c 7c 00 00 LOAD_FAST x 0001dc8f 0c UNARY_NOT 0001dc90 91 01 00 EXTENDED_ARG 1 0001dc93 6f 9f dc JUMP_IF_FALSE_OR_POPL1dc9f 0001dc96 7c 00 00 LOAD_FAST x 0001dc99 74 01 00 LOAD_GLOBAL None 0001dc9c 6b 08 00 COMPARE_OP 'is' L1dc9f: 0001dc9f 91 01 00 EXTENDED_ARG 1 0001dca2 72 ab dc POP_JUMP_IF_FALSE L1dcab 0001dca5 7c 00 00 LOAD_FAST x 0001dca8 6e 03 00 JUMP_FORWARD L1dcae (+3) L1dcab: 0001dcab 7c 00 00 LOAD_FAST x L1dcae: 0001dcae 7d 00 00 STORE_FAST x
On Wed, Apr 13, 2016 at 2:23 PM, Victor Stinner <victor.stinner at gmail.com> wrote:
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: - 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 EXTENDARG, 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, EXTENDEDARG can be seen when MAKEFUNCTION is used with annotations. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160413/194a94ba/attachment.html>
- Previous message (by thread): [Python-Dev] Wordcode: new regular bytecode using 16-bit units
- Next message (by thread): [Python-Dev] Wordcode: new regular bytecode using 16-bit units
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]