On 1 July 2014 10:33, Steven D'Aprano email@example.com wrote:
On Tue, Jul 01, 2014 at 06:38:37PM +1000, Chris Angelico wrote: [...]
- Do I really think anyone *should* do this? Your subsequent comments
support this question, and the answer is resoundingly NO. CPython is
"This" being trying to micro-optimize code by bytecode-hacking.
not the sort of platform on which that kind of thing is ever worth doing. You'll get far more performance by using Cython for parts, or in some other way improving your code, than you will by hand-tweaking the Python bytecode.
I think that micro-optimization is probably the wrong reason to hack bytecodes. What I'm more interested in is exploring potential new features, or to add functionality
https://pypi.python.org/pypi/withhacks and https://pypi.python.org/pypi/byteplay may also be of interest to anyone wishing to seriously tinker with what the CPython VM (as opposed to Python-the-language) already supports. I also highly advise working Python 3.4, since we made some substantial improvements to the dis module API (adding the yield from tests for 3.3 highlighted how limited the previous API was for testing purposes, so we fixed it in a way that made bytecode easier to work with in general).