blog | oilshell.org
In my last post on Recurse Center, I forgot to mention two projects that pulled me in:
They both have an accompanying article:
I'm really grateful for this work, especially because I know how much effort it takes to write both code and prose.
These projects are so close to work I was already doing that it felt like Recurse Center was a natural fit.
They're also a good foundation for understanding this talk:
Excerpts from my notes:
(1) In Python 3.6, bytecode was changed to word code. Instead of encoding each instruction in one or three bytes, depending on whether it has an argument, they're all encoded in two bytes.
EXTENDED_ARGopcode, which I assume can be used when you need three or more bytes.
enumusing only primitive math operations — that is, without branches or lookup tables. In that case, we wanted a function over IDs in a syntax tree; in this case we want one over opcode IDs in instructions. The solution probably isn't directly applicable, but the problem is similar. (I also doubt I'll use it in Oil — it was more of a fun diversion.)
(2) Function calls in Python are expensive, and were optimized in two ways:
This snippet shows that it takes four bytecodes to call a method in Python 2.7 (and presumably 3.5):
>>> def f(obj): ... return obj.method(42) ... >>> import dis >>> dis.dis(f) 2 0 LOAD_FAST 0 (obj) 3 LOAD_ATTR 0 (method) 6 LOAD_CONST 1 (42) 9 CALL_FUNCTION 1 12 RETURN_VALUE
The work on optimization is still in progress, and will be until after my trip, so that's all for now. I wrote a long comment about OPy this morning if you want to follow along more closely.
The next post will flush the blog backlog, as promised in the last post.