<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/category/blog/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Wed, 28 Jul 2010 18:08:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>python &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Loading images via http vs bytearray</title>
		<link>https://blog.sephiroth.it/2009/01/05/loading-images-via-http-vs-bytearray/</link>
					<comments>https://blog.sephiroth.it/2009/01/05/loading-images-via-http-vs-bytearray/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Mon, 05 Jan 2009 22:00:41 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ArrayCollection]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[blazeds]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[charles]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[pyamf]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=270</guid>

					<description><![CDATA[Load images via http or using bytearray? which the best way? It was long time since I wanted to perform this kind of test, but for different reasons I never had the time to do that. Some days ago fnally I&#8217;ve found the time thanks to a project I&#8217;m involved into. The problem. A local &#8230; <a href="https://blog.sephiroth.it/2009/01/05/loading-images-via-http-vs-bytearray/" class="more-link">Continue reading <span class="screen-reader-text">Loading images via http vs bytearray</span></a>]]></description>
										<content:encoded><![CDATA[<div>Load images via <strong>http</strong> or using <strong>bytearray</strong>? which the best way?</div>
<div>It was long time since I wanted to perform this kind of test, but for different reasons I never had the time to do that.</div>
<div>Some days ago fnally I&#8217;ve found the time thanks to a project I&#8217;m involved into.</div>
<div>The problem.</div>
<div>A local webserver running flash remoting via <a href="http://pyamf.org/">pyamf </a>and a flash standalone application which need to load tons of images locally.</div>
<div>I&#8217;ve noticed that sending from amf the list of images path to be loaded required too much time (for me), even if they&#8217;re loaded locally.</div>
<div>Because of this I decided to try a first benchmark loading a single image using the standard way: send the link from amf and then load it using the classic actionscript Loader.<br />
The second test was to send directly from amf the image stream using a ByteArray and then loading the image in flash using the Loader.loadBytes method.</div>
<div>In this way I&#8217;ve noticed that the second task requires less time than the first one (more or less 40% less).</div>
<div>Unfortunately our application needs to load something like 50/100 images at the same time.</div>
<div>For this reason I did a new test loading 22 images of 500Kb each (10Mb total). For a better result I decided to use both pyamf and blazeds, to be sure there&#8217;s no problems in the language used. Moreover I used <a href="http://www.charlesproxy.com/">charles</a> to register the benchmark of these tasks.</div>
<div>The results were unexpected!</div>
<div></div>
<div><strong>First test:</strong> passing form amf the list of url images and loading using the standard flash Loader to load all of them simultaneously.</div>
<div>The time elapsed from the flash method call to the results was about 40 milliseconds. Then from the remote method result to the completion of all Loader about 1400 milliseconds.</div>
<div><span style="border-collapse: collapse; color: #000000; font-size: 12px; line-height: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div><strong>Second test:</strong> passing from amf an arraycollection of bytearrays containing all the images stream to be loaded directly in flash.</div>
<div>The time elapsed form the flash method call to its result: about 2900 milliseconds. Time elapsed from the result to the all Loaders completion: about 900 milliseconds.</div>
<div></div>
<div>This results were unexpected for me, expecially because both with <strong>blazeds</strong> and <strong>pyamf</strong> sending 10Mb of bytearrays tooks something like 3 seconds!<br />
At a first impression I thought the problem was the time for java and python to create the amf stream data, but after a deeper test I discovered that they took more or less 30ms to generate the amf stream and the real bottleneck was the http transfer of this stream data.</div>
<div><span style="border-collapse: collapse; color: #000000; font-size: 12px; line-height: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div>I&#8217;m attaching here the screenshots of the charles sessions using <a href="http://opensource.adobe.com/wiki/display/blazeds">blazeds</a>:</div>
<p><span class="mt-enclosure mt-enclosure-image" style="display: inline;">
<a href='https://blog.sephiroth.it/wp-content/uploads/2009/01/pyamf_charles1.png'><img decoding="async" width="150" height="150" src="https://blog.sephiroth.it/wp-content/uploads/2009/01/pyamf_charles1-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" /></a>
<a href='https://blog.sephiroth.it/wp-content/uploads/2009/01/blazeds_charles1.png'><img decoding="async" width="150" height="150" src="https://blog.sephiroth.it/wp-content/uploads/2009/01/blazeds_charles1-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" /></a>
</p>
<p></span></p>
<div>
<div>
<div></div>
<div>Here you can find also the complete benchmark result using flash trace within the swf:</div>
<div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>BlazeDS</div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>Method<span style="white-space: pre;"> </span>Elapsed-Time</div>
<div>call.test1<span style="white-space: pre;"> </span>0</div>
<div>result.test1<span style="white-space: pre;"> </span>40</div>
<div>complete.test1<span style="white-space: pre;"> </span>1453</div>
<div>TEST1 TOTAL TIME: <span style="white-space: pre;"> </span>1493</div>
<div>call.test2<span style="white-space: pre;"> </span>0</div>
<div>result.test2<span style="white-space: pre;"> </span>2919</div>
<div>complete.test2<span style="white-space: pre;"> </span>921</div>
<div>TEST2 TOTAL TIME: <span style="white-space: pre;"> </span>3840</div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>PyAMF</div>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div>call.test1<span style="white-space: pre;"> </span>0</div>
<div>result.test1<span style="white-space: pre;"> </span>32</div>
<div>complete.test1<span style="white-space: pre;"> </span>953</div>
<div>TEST1 TOTAL TIME: <span style="white-space: pre;"> </span>1049</div>
<div>call.test2<span style="white-space: pre;"> </span>0</div>
<div>result.test2<span style="white-space: pre;"> </span>2805</div>
<div>complete.test2<span style="white-space: pre;"> </span>908</div>
<div>TEST2 TOTAL TIME: <span style="white-space: pre;"> </span>4763</div>
<div></div>
</div>
<div>Here you can see the source code used for these tests:</div>
<div><span class="mt-enclosure mt-enclosure-file" style="display: inline;"></p>
<ul>
<li><a href="https://blog.sephiroth.it/wp-content/uploads/2009/01/Test.java">Test.java</a></li>
<li><a href="https://blog.sephiroth.it/wp-content/uploads/2009/01/test_bytearray.py">test_bytearray.py</a></li>
<li><a href="http://www.sephiroth.it/weblog/archives/test_bytearray.py"></a>and the Flex project: <a href="https://blog.sephiroth.it/wp-content/uploads/2009/01/TestLoadImageFromPyAMF.zip">TestLoadImageFromPyAMF.zip</a></li>
</ul>
<p></span></div>
<div>In conclusion. While sending 10Mb of data ( for example bytearray ) requires more or less 2.5 seconds using flash remoting as single requests ( because the transfer rate of the webserver it&#8217;s about 4Mb/sec ), loading simultaneusly 20 images from the webserver, using http, tooks 1 second.</div>
<div>This is because the webserver for each requests opens a different thread to dispatch the request and in this way the total time to perform this task is less than the first method.</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2009/01/05/loading-images-via-http-vs-bytearray/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Java coffee factory</title>
		<link>https://blog.sephiroth.it/2008/07/15/java-coffee-factory/</link>
					<comments>https://blog.sephiroth.it/2008/07/15/java-coffee-factory/#respond</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Tue, 15 Jul 2008 17:33:21 +0000</pubDate>
				<category><![CDATA[python]]></category>
		<category><![CDATA[java]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=259</guid>

					<description><![CDATA[I just read a really exhilarant post by Digital Davide, unfortunately it&#8217;s only in italian so many of you will not understand that, but for those who can I suggest to take a reading! It&#8217;s really funny and it describes perfectly what I think about Java and java way of coding too &#240;&#159;&#153;&#130; Don&#8217;t miss &#8230; <a href="https://blog.sephiroth.it/2008/07/15/java-coffee-factory/" class="more-link">Continue reading <span class="screen-reader-text">Java coffee factory</span></a>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" src="http://bp1.blogger.com/_tDr3sLnHhcw/R9sOMxctgVI/AAAAAAAAABg/wHplt5pFyb8/s400/400px-Anaconda_ver2.jpg" border="0" alt="" hspace="4" vspace="4" width="112" height="170" align="right" />I just read a really exhilarant post by <a href="http://powerjibe.blogspot.com/" target="_blank">Digital Davide</a>, unfortunately it&#8217;s only in italian so many of you will not understand that, but for those who can I suggest to take a reading!<br />
It&#8217;s really funny and it describes perfectly what I think about Java and java way of coding too 🙂</p>
<p>Don&#8217;t miss to read <strong>&#8220;<a href="http://powerjibe.blogspot.com/2008/03/cura-dellanicagis.html" target="_blank">Il pitone dell&#8217;isola di Java</a>&#8220;</strong> !</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2008/07/15/java-coffee-factory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Flashlite and python games for my Nokia</title>
		<link>https://blog.sephiroth.it/2007/04/25/flashlite-and-python-games-for-my-nokia/</link>
					<comments>https://blog.sephiroth.it/2007/04/25/flashlite-and-python-games-for-my-nokia/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Thu, 26 Apr 2007 05:06:44 +0000</pubDate>
				<category><![CDATA[python]]></category>
		<category><![CDATA[asteroids]]></category>
		<category><![CDATA[cs3]]></category>
		<category><![CDATA[ensymble]]></category>
		<category><![CDATA[flashlite]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[py2sis]]></category>
		<category><![CDATA[pys60]]></category>
		<category><![CDATA[swf2go]]></category>
		<category><![CDATA[symbian]]></category>
		<category><![CDATA[tetris]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=214</guid>

					<description><![CDATA[<p>Last week I bought my new mobile and I got a Nokia N73 phone.<br />After the first days playing with themes and ring tones, as usual with new toys :), I installed <span style="font-weight: bold">Flashlite 2.1</span>! I must admit I never used and seen it before... so I decided to make a first quick experiment making a simple game.<br />Lucky that Adobe Device Central CS3 has just been released, so I could test the swf in different environments (even if I didnt understand how phones flashlite versions could be changed in the device central phone list..).</p><p>Anyway, finally I made this simple <span style="font-weight: bold">tetris</span> remake with flashlite 2.1.<br />If you want to broke your phone you can try install it from here:<br /><a target="_blank" href="http://www.sephiroth.it/_temp/s60/tetrix.zip">http://www.sephiroth.it/_temp/s60/tetrix.zip</a></p><p>I also followed some tuts about creating .sis installer (for symbian phones) from <a target="_blank" href="http://www.adobe.com/devnet/devices/articles/s60_swf_launcher.html">here</a> and also trying using other tolls such as <a target="_blank" href="http://www.google.com/url?sa=t&#38;ct=res&#38;cd=1&#38;url=http%3A%2F%2Fwww.orison.biz%2Fproducts%2Fswf2go%2F&#38;ei=lNMvRqC0KYrMgwSihJS4Cg&#38;usg=AFrqEzcjP78gJqNkcz3MoDYphXJotr7iQw&#38;sig2=YZvDhN4KSrsh4hOF6saoYg">SWF2GO</a> but unfortunately I wan't able to do that :(</p><p>Python... oh python :)<br />Then I discovered that there was a python version for series 60 (<a target="_blank" href="http://wiki.opensource.nokia.com/projects/Installing_PyS60">PyS60</a>). I couldn't believe to my eyes when I opened the Python shell from the phone! LOL</p> <p>So, why not trying to make something also with python? After installing tons and tons of software from Nokia, tutorials and example files I finally managed to start creating simple apps. Also this time I started with a simple game (my second fav arcade game): <span style="font-weight: bold">Asteroids</span>.<br />This time I also managed to create the .sis file, even if not with the suggested process with <a target="_blank" href="http://www.mobilenin.com/pys60/info_standalone_application.htm">py2sis</a>, but using only <a target="_blank" href="http://www.nbl.fi/~nbl928/ensymble.html">Ensymble</a>.<br /> You can download the .sis file from here: <a target="_blank" href="http://www.sephiroth.it/_temp/s60/asteroidz.sis">http://www.sephiroth.it/_temp/s60/asteroidz.sis</a> <br /> The source file (if you can't install the sis) is here: <a target="_blank" href="http://www.sephiroth.it/_temp/s60/asteroidz.py">http://www.sephiroth.it/_temp/s60/asteroidz.py<br /> </a></p> <p>Anyway, please note that this is incomplete, it's merely a test just for understand the python graphical api from Nokia.<br /> </p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://blog.sephiroth.it/wp-content/uploads/2007/04/tetrix_preview.png"><img loading="lazy" decoding="async" class="alignleft size-full wp-image-987" style="margin: 4px;" title="tetrix_preview" src="https://blog.sephiroth.it/wp-content/uploads/2007/04/tetrix_preview.png" alt="" width="150" height="193" /></a>Last week I bought my new mobile and I got a Nokia N73 phone.<br />
After the first days playing with themes and ring tones, as usual with new toys :), I installed <span style="font-weight: bold;">Flashlite 2.1</span>! I must admit I never used and seen it before&#8230; so I decided to make a first quick experiment making a simple game.<br />
Lucky that Adobe Device Central CS3 has just been released, so I could test the swf in different environments (even if I didnt understand how phones flashlite versions could be changed in the device central phone list..).</p>
<p>Anyway, finally I made this simple <span style="font-weight: bold;">tetris</span> remake with flashlite 2.1.<br />
If you want to broke your phone you can try install it from here:<br />
[attachments size=small docid=989 fields=none force_saveas=&#8221;1&#8243; logged_users=&#8221;0&#8243;]</p>
<p>I also followed some tuts about creating .sis installer (for symbian phones) from <a href="http://www.adobe.com/devnet/devices/articles/s60_swf_launcher.html" target="_blank">here</a> and also trying using other tolls such as <a href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.orison.biz%2Fproducts%2Fswf2go%2F&amp;ei=lNMvRqC0KYrMgwSihJS4Cg&amp;usg=AFrqEzcjP78gJqNkcz3MoDYphXJotr7iQw&amp;sig2=YZvDhN4KSrsh4hOF6saoYg" target="_blank">SWF2GO</a> but unfortunately I wan&#8217;t able to do that 🙁</p>
<p>Python&#8230; oh python 🙂<br />
Then I discovered that there is a python version for series 60 (<a href="http://wiki.opensource.nokia.com/projects/Installing_PyS60" target="_blank">PyS60</a>). I couldn&#8217;t believe to my eyes when I opened the Python shell from the phone menu! LOL</p>
<p>So, why not trying to make something also with python?<br />
After installing tons and tons of software from Nokia, tutorials and example files I finally managed to start creating simple apps. Also this time I started with a simple game (my second fav arcade game): <span style="font-weight: bold;">Asteroids</span>.<br />
This time I also managed to create the .sis file, even if not with the suggested process with <a href="http://www.mobilenin.com/pys60/info_standalone_application.htm" target="_blank">py2sis</a>, but using only <a href="http://www.nbl.fi/~nbl928/ensymble.html" target="_blank">Ensymble</a> with this command:<br />
<code>ensymble_python2.5-0.22.py py2sis asteroidz.py asteroidz.sis --uid=0xA0002E1F --appname=asteroidz --caps="NONE" --lang=EN --shortcaption="asteroidz" --cert=mycert.cer --privkey=mykey.key --passphrase=password --verbose --version=1.0.1</code><br />
You can download the <strong>.sis</strong> file and the source directly here (it requires <strong>python series 60 1.3.20</strong> already installed):</p>
<p>[attachments docid=990 force_saveas=&#8221;1&#8243; logged_users=&#8221;0&#8243;]</p>
<p style="font-style: italic;">Anyway, please note that this is incomplete, it&#8217;s merely a test just for understand the python graphical api from Nokia.</p>
<p>I just discovered a new world 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2007/04/25/flashlite-and-python-games-for-my-nokia/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>Actionscript parsing experiences: PyBison &#038; PLY</title>
		<link>https://blog.sephiroth.it/2007/01/16/actionscript-parsing-experiences-pybison-ply/</link>
					<comments>https://blog.sephiroth.it/2007/01/16/actionscript-parsing-experiences-pybison-ply/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Tue, 16 Jan 2007 21:35:45 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[antlr]]></category>
		<category><![CDATA[ast]]></category>
		<category><![CDATA[bison]]></category>
		<category><![CDATA[e4x]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[ply]]></category>
		<category><![CDATA[pybison]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=195</guid>

					<description><![CDATA[My experiments with actionscript text-parsing continue, This time I tested two bison python implementations: pybison and ply.<br />
]]></description>
										<content:encoded><![CDATA[<p>My experiments with text-parsing continue..</p>
<p><span style="font-weight: bold;">PyBison</span><br />
Last day I founded a python library <a title="pybison" href="http://www.freenet.org.nz/python/pybison/" target="_blank">(pybison</a>) which runs the generated python parser at near the speed of C-based parsers, due to direct hooks into bison-generated C code.<br />
Cool, unfortunately I couldn&#8217;t compiled it for Windows and so I made my test on Ubuntu only. What I did was just to export the already written lexer/grammar using bison2py (boundled with pybison) and run it.</p>
<p>If you want to take a look at the python parser try it by downloading the source code here.<br />
The run.py file accept these parameters:<br />
<code>usage: run.py [options]<br />
options:<br />
-h, --help            show this help message and exit<br />
-v, --verbose         Turn on verbose mode<br />
-o OUTPUT_FILE, --output=OUTPUT_FILE<br />
Don't print to stdout but to the output file<br />
-i INPUT_FILE, --input=INPUT_FILE<br />
Input file to be parsed<br />
-x, --to-xml          Returns a human-readable xml representation of the<br />
parse tree<br />
-b, --bison-debug     Print the Bison/Flex debug</code><br />
You can download the source code <a title="pybison code source code" href="https://blog.sephiroth.it/wp-content/uploads/2007/01/pybison.tar.gz">here</a></p>
<p><span style="font-weight: bold;">PLY</span><br />
The second test I did was using <a href="http://www.dabeaz.com/ply/" target="_blank">PLY</a>, an implementation of  lex and yacc parsing tools for Python. Being implemented entirely in python it should be much more slower that pybison, but I didn&#8217;t find any difference with the pybison parser version. In fact PLY , like the traditional bison, creates tables starting from the grammar syntax.<br />
Ok, Both of the implementations are slower that the pure C parser, but extremely faster that <span style="font-weight: bold;">antlr</span>!<br />
(They took more or less 0.02 to 0.5 secs for parsing and generating the AST.)<br />
Unlike pybison PLY is still mantained and offers more features and a better error handling.. even if the whole grammar has to be rewritten in python, and it can be compiled in Windows too.</p>
<p>To run the test just write:<br />
<code>python run.py {filename}</code><br />
<span style="font-weight: bold;">P.S.</span> Unfortunately the yacc parser isn&#8217;t yet complete because I still need to find a way for parsing correctly E4X and XML syntax..</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2007/01/16/actionscript-parsing-experiences-pybison-ply/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>ActionScript Parsing, the YACC revenge :)</title>
		<link>https://blog.sephiroth.it/2006/12/10/actionscript-parsing-the-yacc-revenge/</link>
					<comments>https://blog.sephiroth.it/2006/12/10/actionscript-parsing-the-yacc-revenge/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Mon, 11 Dec 2006 00:47:30 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[antlr]]></category>
		<category><![CDATA[bison]]></category>
		<category><![CDATA[ecma]]></category>
		<category><![CDATA[ecmascript]]></category>
		<category><![CDATA[elastic]]></category>
		<category><![CDATA[gnu flex]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[pyrex]]></category>
		<category><![CDATA[yacc]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=188</guid>

					<description><![CDATA[After my first <a target="_blank" href="http://www.sephiroth.it/weblog/archives/2006/12/an_experience_with_antlr_with_java_an.php">attempts with ANTLR</a> scanners in python/java I decided to start back with Bison/Flex again to see the difference in performances...
]]></description>
										<content:encoded><![CDATA[<p>After my first <a title="An experience with antlr, java and python" href="https://blog.sephiroth.it/2006/12/01/an-experience-with-antlr-java-and-python/" target="_blank">attempts with ANTLR</a> scanners in python/java I decided to start back with Bison/Flex again to see the difference in performances.<br />
So first I need to wrote from scratch the grammar/lexer files using only the <a href="http://www.mozilla.org/js/language/es4/" target="_blank">ECMAScript 4</a> specifications and much patience (the <a href="http://svn.berlios.de/wsvn/elastic/trunk/elastiC/src/elastic_p.y?op=file&amp;rev=0&amp;sc=0">elastic grammar file</a> help me a lot too).</p>
<p>After finishing a first version of the parser I tested it on the same file (75Kb actionscript file) which both java and python parsed in more than 1 second.<br />
The result was unbelievable: <span style="font-weight: bold;">0.02</span> seconds for that file!</p>
<p>Then I tested it on multiple files, and for about 320 files of the whole adobe corelib library it took 220ms</p>
<p>Ok, the parser it&#8217;s not yet complete and doesn&#8217;t care about regexp and xml syntax, but its performance convinced me enough&#8230;<br />
Now, the next step is to finish and test the parser and finally create a python library using <a href="http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/" target="_blank">pyrex</a>, then a benchmark test again.</p>
<p>If someone is interested in testing the parser, <a href="https://blog.sephiroth.it/wp-content/uploads/2006/12/parser.exe">download it</a> (use &#8220;<span style="font-style: italic;">parser &#8211;help</span>&#8221; form the command line for usage help), but remember this is only a first test.. not really helpful right now (I just wanted to share my text/parsing experiences).</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/12/10/actionscript-parsing-the-yacc-revenge/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>An experience with antlr, java and python</title>
		<link>https://blog.sephiroth.it/2006/12/01/an-experience-with-antlr-java-and-python/</link>
					<comments>https://blog.sephiroth.it/2006/12/01/an-experience-with-antlr-java-and-python/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 01 Dec 2006 19:09:11 +0000</pubDate>
				<category><![CDATA[general]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[antlr]]></category>
		<category><![CDATA[asdt]]></category>
		<category><![CDATA[bison]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ecma]]></category>
		<category><![CDATA[gnu flex]]></category>
		<category><![CDATA[grammar]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[profiler]]></category>
		<category><![CDATA[psyco]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=187</guid>

					<description><![CDATA[I just wanted to share a little experience with generating an AS3 parser using antlr and python.I was trying first to create the parser using...
]]></description>
										<content:encoded><![CDATA[<p>I just wanted to share a little experience with generating an AS3 parser using <a href="http://www.antlr.org">antlr</a> and <a href="http://www.python.org">python</a>.<br />
I was trying first to create the parser using GNU <a title="gnu flex" href="http://www.gnu.org/software/flex/" target="_blank">Flex</a> and <a title="gnu bison" href="http://www.gnu.org/software/bison/" target="_blank">Bison</a> in C, probably the best way for a very performancing parser.<br />
Yeah, that&#8217;s right.. but looking at the antlr syntax I realized that&#8217;s easier and easier.<br />
Moreover I start using this very useful <a title="antlrstudio" href="http://www.placidsystems.com/antlrstudio.aspx" target="_blank">eclipse plugin</a> for antlr debugging which made my life easier!</p>
<p>The grammar file I created is a compromise between the <a title="as3.g" href="http://www.google.com/codesearch?hl=it&amp;q=+file:%5C.g%24+as3.g+show:gFeBx72kxIk:XKFG9i76Jiw:mSlmdOLa2XQ&amp;sa=N&amp;cd=1&amp;ct=rc&amp;cs_p=:pserver:anonymous%40aseclipseplugin.cvs.sourceforge.net:/cvsroot/aseclipseplugin+org.asdt.astview&amp;cs_f=src/org/asdt/core/internal/antlr/as3.g#a0" target="_blank">asdt grammar</a> file and the <a title="ECMA-262 specifications" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" target="_blank">ECMA-262 grammar</a> specification.</p>
<p>Once finished working on my eclipse project I&#8217;ve managed to parse succesfully all the adobe corelibs files using this java test file:<br />
<code lang="java">package org.sepy.core.parsers.as3;<br />
import java.io.File;<br />
import java.io.FileInputStream;<br />
import java.io.FileNotFoundException;<br />
import antlr.CommonAST;<br />
import antlr.RecognitionException;<br />
import antlr.TokenStreamException;<br />
public class Application {<br />
public static void main(String argv[])<br />
{<br />
if(argv.length &gt; 0)<br />
{<br />
File file = new File(argv[0]);<br />
if(file.exists())<br />
{<br />
FileInputStream is = null;<br />
try {<br />
is = new FileInputStream(file);<br />
} catch (FileNotFoundException e) {<br />
// TODO Auto-generated catch block<br />
e.printStackTrace();<br />
}<br />
AS3Lexer L = new AS3Lexer(is);<br />
AS3Parser P = new AS3Parser(L);<br />
try {<br />
P.compilationUnit();<br />
} catch (RecognitionException e) {<br />
// TODO Auto-generated catch block<br />
System.out.println(" line=" + e.line + ", column="+ e.column);<br />
System.out.println(e.getMessage());<br />
e.printStackTrace(System.err);<br />
} catch (TokenStreamException e) {<br />
// TODO Auto-generated catch block<br />
System.out.println(" line=" + L.getLine() + ", column="+ L.getColumn());<br />
System.out.println(L.getGuessInfo());<br />
System.out.println(e.getMessage());<br />
e.printStackTrace(System.err);<br />
}<br />
CommonAST.setVerboseStringConversion(false, P.getTokenNames());<br />
CommonAST ast = (CommonAST) P.getAST();<br />
System.out.println("Tree:");<br />
System.out.println(ast.toStringTree());<br />
}<br />
}<br />
}<br />
}</code><br />
Ok, done that I decided to export the grammar file for python (thanks to antrl python export feature).<br />
Everything works fine also for python, but I realized that the python script were so much slower than the java one!<br />
<code lang="python">import sys<br />
import antlr<br />
import AS3Parser<br />
import AS3Lexer<br />
L = AS3Lexer.Lexer(filename);<br />
P = AS3Parser.Parser(L);<br />
P.setFilename(filename)<br />
try:<br />
   P.compilationUnit();<br />
   ast = P.getAST();<br />
except:<br />
   pass<br />
</code><br />
On a 75Kb actionscript file the python script took about 7 seconds to run, while the java application only 2 seconds. I know python interpreter caould be slower than many other languages, but I never thought so much slower.<br />
So I run the python <a href="http://docs.python.org/lib/module-hotshot.html" target="_blank">hotshot profiler</a> to see which could be the bottleneck in the python script and I found most of the problems were due to unuseless antlr (the python module) method&#8217;s calls.<br />
After making corrections to the antlr.py file the same script took exactly half of the time. Now 3 seconds. Wow 🙂<br />
But not fast enough.<br />
So I enabled for the antlr python script <a href="http://psyco.sourceforge.net/" target="_blank">psyco</a> module and this time the same script took <strong>only 1.6 seconds.</strong><br />
Now the python script is fast enough, even if I&#8217;m sure I can make more optimizations in the antlr module&#8230;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/12/01/an-experience-with-antlr-java-and-python/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Red5 with javascript python ruby and coffee?</title>
		<link>https://blog.sephiroth.it/2006/10/18/red5-with-javascript-python-ruby-and-coffee/</link>
					<comments>https://blog.sephiroth.it/2006/10/18/red5-with-javascript-python-ruby-and-coffee/#respond</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Wed, 18 Oct 2006 09:03:15 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash media server]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[red5]]></category>
		<category><![CDATA[ruby]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=175</guid>

					<description><![CDATA[red5 with javascript python ruby and java?<br />
]]></description>
										<content:encoded><![CDATA[<p><a title="Red5" href="http://osflash.org/red5">Red5</a> (the opensource flash multimedia server) will support server side javascript, Ruby, <a title="Python" href="http://www.python.org"><strong>Python</strong></a> and Java?<br />
That&#8217;s terrific!<br />
Well, it seems the next 0.6 RC1 version of Red5 will do that! The release is scheduled by next Monday and if that&#8217;s true I definitively will find the time to look inside it 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/10/18/red5-with-javascript-python-ruby-and-coffee/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Installing python msi on Windows Vista</title>
		<link>https://blog.sephiroth.it/2006/06/22/installing-python-msi-on-windows-vista/</link>
					<comments>https://blog.sephiroth.it/2006/06/22/installing-python-msi-on-windows-vista/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Thu, 22 Jun 2006 16:52:33 +0000</pubDate>
				<category><![CDATA[general]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[msiexec]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=150</guid>

					<description><![CDATA[install python msi package on windows vista using msiexec
]]></description>
										<content:encoded><![CDATA[<p>Finally I&#8217;ve managed to install python on my Windows Vista!<br />
Every time I tried to install the .msi package it was stopping work just after selecting the destination folder and I was going crazy to find a solution..<br />
Then I managed to install it correctly using <strong><a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/msiexec.mspx?mfr=true">msiexec</a></strong></p>
<pre class="tutorialCode">msiexec /i python-2.4.3.msi TARGETDIR="C:\Program Files\Python24" ALLUSERS=1 /qb</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/06/22/installing-python-msi-on-windows-vista/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>From flashticle import swf</title>
		<link>https://blog.sephiroth.it/2006/04/22/from-flashticle-import-swf/</link>
					<comments>https://blog.sephiroth.it/2006/04/22/from-flashticle-import-swf/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Sat, 22 Apr 2006 18:34:56 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[flashticle]]></category>
		<category><![CDATA[osflash]]></category>
		<category><![CDATA[pyswf]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=136</guid>

					<description><![CDATA[During the reading of one of the articles at osflash I&#8217;ve got inspiration (and portion of the code) from flashticle project to start with a little project by myself (called pyswf). That&#8217;s not *really* a project, also because there are so many decrypers, disassemblers, optimizators etc around here, but more an exercize for better understand &#8230; <a href="https://blog.sephiroth.it/2006/04/22/from-flashticle-import-swf/" class="more-link">Continue reading <span class="screen-reader-text">From flashticle import swf</span></a>]]></description>
										<content:encoded><![CDATA[<p>During the reading of one of the articles at <a href="http://www.osflash.org">osflash</a> I&#8217;ve got inspiration (and portion of the code) from <a href="http://www.osflash.org/flashticle">flashticle</a> project to start with a little project by myself (called <span style="font-weight: bold;">pyswf</span>).<br />
That&#8217;s not *really* a project, also because there are so many decrypers, disassemblers, optimizators etc around here, but more an exercize for better understand both python and the SWF file format&#8230;<br />
BTW, currently it can read quite almost all swf tags and actions, writing them in a pseudo-code (later i will try to create the original actionscript code), and also extract some of the swf embedded multimedia objects (such as flv, mp3, wav, and images)<br />
for example:<br />
<code><strong>main -e "test.swf"</strong></code><br />
it will print all the swf code in the output buffer and also extract all the multimedia files embedded into test.swf<br />
you can download the source code (with also a win32 binary) <a rel="nofollow" href="http://www.sephiroth.it/python/pyswf/pyswf.zip">from here</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/04/22/from-flashticle-import-swf/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Flash remoting for python</title>
		<link>https://blog.sephiroth.it/2004/07/13/flash-remoting-for-python/</link>
					<comments>https://blog.sephiroth.it/2004/07/13/flash-remoting-for-python/#respond</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Wed, 14 Jul 2004 06:34:09 +0000</pubDate>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[remoting]]></category>
		<category><![CDATA[serializer]]></category>
		<category><![CDATA[xpath]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=16</guid>

					<description><![CDATA[Yesterday I received an email form Vsevolod ILyushchenko announcing me the alpha version of Flash remoting for python! http://simonf.com/amfpython/. There are also many examples here: http://simonf.com/amfpython/code.html Second update: Serializer Class 2.1 There is a bug fixing with in special chars lenght, thanks to Rainer Becker. The new mxp file is available on the sourceforge site. &#8230; <a href="https://blog.sephiroth.it/2004/07/13/flash-remoting-for-python/" class="more-link">Continue reading <span class="screen-reader-text">Flash remoting for python</span></a>]]></description>
										<content:encoded><![CDATA[<p><span class="normalText">Yesterday I received an email form Vsevolod ILyushchenko announcing me the alpha version of <strong>Flash remoting for python</strong>!<br />
<a href="http://simonf.com/amfpython/">http://simonf.com/amfpython/</a>. There are also many examples here: <a href="http://simonf.com/amfpython/code.html">http://simonf.com/amfpython/code.html</a></span></p>
<p>Second update: <strong><a href="http://sourceforge.net/projects/serializerclass/">Serializer Class 2.1</a></strong><br />
There is a bug fixing with in special chars lenght, thanks to <strong>Rainer Becker</strong>. The new mxp file is available on the sourceforge site.</p>
<p>Last thing. I&#8217;ve just uploaded an example which <strong>Daniel Tavelli</strong> send me.<br />
<a href="http://www.sephiroth.it/file_detail.php?id=130">An example of Xpath usage in flash mx 2004</a> using the <a href="http://www.xfactorstudio.com/">xfactorstudio</a> xpath class for ActionScript</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2004/07/13/flash-remoting-for-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
