{"id":51,"date":"2007-12-22T13:11:54","date_gmt":"2007-12-22T19:11:54","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/2007\/12\/22\/64k-version-of-python-is-4234x-faster-than-c-python\/"},"modified":"2008-02-19T01:14:09","modified_gmt":"2008-02-19T07:14:09","slug":"64k-version-of-python-is-4234x-faster-than-c-python","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2007\/12\/22\/64k-version-of-python-is-4234x-faster-than-c-python\/","title":{"rendered":"64k version of python is 4234x faster* than c-python!"},"content":{"rendered":"<p>To satisfy some sick curiosity of mine, I decided to write a miniature version of python in less than 64k of code.  The code includes a tokenizer (which works rather well) a parser (which sort of works ) a translator (which does the job).  All of those bits are written in python.  The last bit is the C library I wrote to handle all the grit.  That part isn&#8217;t so good.<\/p>\n<p>To sum up, my implementation does very little, and what it does, it does very slowly.  Most of the speed is spent up in memory allocation (my best guess).  I wish I had a julia screenshot to show you, but I don&#8217;t think I have the patience, nor the RAM, to provide you with the pleasure.<\/p>\n<p>If you wish to witness the horrors, feel free to check out svn:\/\/www.imitationpickles.org\/tinypy\/trunk &#8230; Please don&#8217;t look too closely.  I think if I really want to work on this sort of stuff my time would be better spent either:<\/p>\n<ul>\n<li>Learning the python C API or ctypes so I can do stuff without SWIG.  (I&#8217;ve liked SWIG, but all the magic makes me nervous.)<\/li>\n<li>Contribute to shed-skin, and add some features I&#8217;d like to it<\/li>\n<li>Contribute to PyPy-Rpython, and add some features I&#8217;d like to it<\/li>\n<li>Wait for py3k, where hopefully someone will write some magic code that uses the swell function annotation features to make fast things happen.<\/li>\n<\/ul>\n<p>Of my options, learning the C-Python API (or maybe ctypes) is probably the easiest answer &#8211; I&#8217;d get all the fun of python, and I&#8217;d get my C speed.  Between working on shed-skin and PyPy &#8212; my feeling is that I really wish shed-skin generated C code or that PyPy-Rpython wasn&#8217;t so huge and scary.  All that said, I&#8217;ll probably just wait for py3k and hope \ud83d\ude09<\/p>\n<p>*today is opposite day!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To satisfy some sick curiosity of mine, I decided to write a miniature version of python in less than 64k of code. The code includes a tokenizer (which works rather well) a parser (which sort of works ) a translator (which does the job). All of those bits are written in python. The last bit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,6,8,2,32],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-crazy","category-development","category-languages","category-python","category-tinypy"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":0,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}