<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PHP Faster than Python?</title>
	<atom:link href="http://www.akngo.com/webdev/php-faster-than-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.akngo.com/webdev/php-faster-than-python/</link>
	<description>I&#039;m a PC, Program Counter</description>
	<lastBuildDate>Wed, 13 Jul 2011 05:49:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Jaime Pinheiro</title>
		<link>http://www.akngo.com/webdev/php-faster-than-python/comment-page-1/#comment-4693</link>
		<dc:creator>Jaime Pinheiro</dc:creator>
		<pubDate>Mon, 28 Mar 2011 21:00:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.akngo.com/webdev/php-faster-than-python/#comment-4693</guid>
		<description>Don&#039;t you forget that array in PHP isn&#039;t really an array, but an array of key =&gt; value pair, just like a hash or dictionary. For that reason, working with arrays in PHP isn&#039;t not as fast it could be and it&#039;s obviously slower than a REAL array should.

Try to compare it to a similar Python object, rather than a simple [].</description>
		<content:encoded><![CDATA[<p>Don&#8217;t you forget that array in PHP isn&#8217;t really an array, but an array of key =&gt; value pair, just like a hash or dictionary. For that reason, working with arrays in PHP isn&#8217;t not as fast it could be and it&#8217;s obviously slower than a REAL array should.</p>
<p>Try to compare it to a similar Python object, rather than a simple [].</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A.K.</title>
		<link>http://www.akngo.com/webdev/php-faster-than-python/comment-page-1/#comment-356</link>
		<dc:creator>A.K.</dc:creator>
		<pubDate>Wed, 11 Feb 2009 00:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.akngo.com/webdev/php-faster-than-python/#comment-356</guid>
		<description>Brandon,
LOL, you are such a prick.

Antti,
Those are very interesting observations. I would expect the same results for the same modifications in PHP as well. Sorry about the formatting, I didn&#039;t install a plugin for comment coding.</description>
		<content:encoded><![CDATA[<p>Brandon,<br />
LOL, you are such a prick.</p>
<p>Antti,<br />
Those are very interesting observations. I would expect the same results for the same modifications in PHP as well. Sorry about the formatting, I didn&#8217;t install a plugin for comment coding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antti Kaihola</title>
		<link>http://www.akngo.com/webdev/php-faster-than-python/comment-page-1/#comment-355</link>
		<dc:creator>Antti Kaihola</dc:creator>
		<pubDate>Tue, 10 Feb 2009 09:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.akngo.com/webdev/php-faster-than-python/#comment-355</guid>
		<description>I tried the following subtle changes to see how they affect the performance:

    import array ; primeNumbers = array(&#039;L&#039;)
     -&gt; almost twice as slow

    if 0 == i % number:
     -&gt; no change

    if not i % number:
     -&gt; slight speedup

    divisible = [1 for number in primeNumbers if i % number == 0]
    if not divisible:
     -&gt; no change

    divisible = [1 for number in primeNumbers if not i % number]
    if not divisible:
     -&gt; slight speedup

That&#039;s all I could come up with without significantly changing what the code does.

Two interesting variations which superficially don&#039;t change the algorithm but actually stop the loop at first match:

    divisible = (1 for number in primeNumbers if i % number == 0)
    try:
        divisible.next()
    except StopIteration:
        primeNumbers.append(i)

A version using Python 2.5 any():

    for i in xrange(2, 10000):
        divisible = any(i % number == 0 for number in primeNumbers)
        if not divisible:
            primeNumbers.append(i)

These two of course are in fact changing the algorithm.


(by the way, you have no help for comment formatting so I don&#039;t know if my code blocks will format correctly)</description>
		<content:encoded><![CDATA[<p>I tried the following subtle changes to see how they affect the performance:</p>
<p>    import array ; primeNumbers = array(&#8216;L&#8217;)<br />
     -&gt; almost twice as slow</p>
<p>    if 0 == i % number:<br />
     -&gt; no change</p>
<p>    if not i % number:<br />
     -&gt; slight speedup</p>
<p>    divisible = [1 for number in primeNumbers if i % number == 0]<br />
    if not divisible:<br />
     -&gt; no change</p>
<p>    divisible = [1 for number in primeNumbers if not i % number]<br />
    if not divisible:<br />
     -&gt; slight speedup</p>
<p>That&#8217;s all I could come up with without significantly changing what the code does.</p>
<p>Two interesting variations which superficially don&#8217;t change the algorithm but actually stop the loop at first match:</p>
<p>    divisible = (1 for number in primeNumbers if i % number == 0)<br />
    try:<br />
        divisible.next()<br />
    except StopIteration:<br />
        primeNumbers.append(i)</p>
<p>A version using Python 2.5 any():</p>
<p>    for i in xrange(2, 10000):<br />
        divisible = any(i % number == 0 for number in primeNumbers)<br />
        if not divisible:<br />
            primeNumbers.append(i)</p>
<p>These two of course are in fact changing the algorithm.</p>
<p>(by the way, you have no help for comment formatting so I don&#8217;t know if my code blocks will format correctly)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bwilliam</title>
		<link>http://www.akngo.com/webdev/php-faster-than-python/comment-page-1/#comment-354</link>
		<dc:creator>bwilliam</dc:creator>
		<pubDate>Tue, 10 Feb 2009 08:35:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.akngo.com/webdev/php-faster-than-python/#comment-354</guid>
		<description>Haha.  This is great.  AK FTW.</description>
		<content:encoded><![CDATA[<p>Haha.  This is great.  AK FTW.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

