<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bytecode on Shai Asher</title><link>https://slow-is-smooth.io/tags/bytecode/</link><description>Recent content in Bytecode on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 10 Jun 2018 09:00:00 +0300</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/bytecode/index.xml" rel="self" type="application/rss+xml"/><item><title>The Loop That Runs Your Bytecode</title><link>https://slow-is-smooth.io/blog/the-loop-that-runs-your-bytecode/</link><pubDate>Sun, 10 Jun 2018 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/the-loop-that-runs-your-bytecode/</guid><description>&lt;p&gt;On Ubuntu 18.04, a five-line Python function that adds up a list compiles to 30 bytes: fifteen&#10;instructions of two bytes each. Running it means one C function, &lt;code&gt;_PyEval_EvalFrameDefault&lt;/code&gt;,&#10;reading those bytes two at a time and jumping, through a table of 256 addresses inside itself, to&#10;the C code for each instruction. On the machine I measured, reading a local variable added 0.6&#10;nanoseconds to each pass of a loop. Reading a global cost five times as much, and fetching a method&#10;cost seventeen times as much. A debugger&amp;rsquo;s trace hook made the whole loop nine times slower.&lt;/p&gt;</description></item></channel></rss>