<br><div class="gmail_quote">On Thu, Jan 22, 2009 at 10:59 PM, joe <span dir="ltr"><<a href="mailto:joeedh@gmail.com">joeedh@gmail.com</a>></span> wrote:<br>...<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
* Use direct threading (which is basically optimizing switch statements to<br>
  be only one or two instructions) for the bytecode loop.</blockquote><div><br>fyi - <a href="http://bugs.python.org/issue4753">http://bugs.python.org/issue4753</a> does this (at least when using gcc).<br><br>The optimization is not about removing instructions per se. but in getting rid of the single switch statement's unpredictable branch that causes modern cpus to stall while determining the correct place to jump rather than speculatively guessing correctly a significant portion of the time.<br>
 <br>...<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
* Remove string lookups for member access entirely, and replaced with a<br>
  system of unique identifyers.  The idea is you would use a hash in the<br>
  types to map a member id to an index.  Hashing ints is faster then strings,<br>
  and I've even thought about experimenting with using collapsed arrays instead<br>
  of hashes.  Of course, the design would still need to support string lookups<br>
  when necessary.  I've thought about this a lot, and I think you'd need the<br>
  same general idea as V8's hidden classes for this to work right (though<br>
  instead of classes, it'd just be member/unique id lookup maps).</blockquote><div><br>Python strings are already immutable, their hash is computed only once. strings used in code as attributes are interned so that all occurances of that string are the same object making the most common lookups for attribute accesses a table lookup with a pointer equality check.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I'm not sure I'll have the time to anytime soon to prototype these ideas, but I<br>
thought I'd kick them out there and see what people say.  Note, I'm in no way<br>
suggesting any sort of change to the existing cpython VM (it's way, way too<br>
early for that kind of talk).</blockquote><div><br>Anyways, the ideas are great and are definately all things people are considering.  This should be an great year for python performance and all language VM performance in general.<br>
<br>happy hacking,<br></div>Greg<br><br></div>