<?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>schmichael&#039;s blog &#187; xml</title>
	<atom:link href="http://blog.schmichael.com/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.schmichael.com</link>
	<description>good good study, day day up</description>
	<lastBuildDate>Sat, 05 Nov 2011 23:13:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>lxml vs. ElementTree</title>
		<link>http://blog.schmichael.com/2009/10/14/lxml-vs-elementtree/</link>
		<comments>http://blog.schmichael.com/2009/10/14/lxml-vs-elementtree/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 23:18:31 +0000</pubDate>
		<dc:creator>Michael Schurter</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[benchmarks]]></category>
		<category><![CDATA[ElementTree]]></category>
		<category><![CDATA[lxml]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://michael.susens-schurter.com/blog/?p=736</guid>
		<description><![CDATA[While lxml has some excellent benchmarks about the speed of lxml.etree vs. ElementTree, I wanted to run some tests that were as close as possible to my own use case (fairly simple multi-megabyte XML files). Here are the results of &#8230; <a href="http://blog.schmichael.com/2009/10/14/lxml-vs-elementtree/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While lxml has some <a href="http://codespeak.net/lxml/performance.html">excellent benchmarks about the speed of lxml.etree vs. ElementTree</a>, I wanted to run some tests that were as close as possible to my own use case (fairly simple multi-megabyte XML files).</p>
<p>Here are the results of my little test script <a href="http://blog.schmichael.com/files/lxml-v-etree.py-remove-me">lxml-v-etree.py</a> (times are in milliseconds):</p>
<pre>
name           generate | tostring | total | write | parse | find | total
------------------------+----------+-------+-------+-------+------+------
xml.cElementTree    132 |   2430   |  2562 |  2433 |   158 |   58 |   216
xml.cElementTree    112 |   2384   |  2497 |  2387 |   158 |   25 |   183
xml.cElementTree    113 |   2393   |  2507 |  2396 |   161 |   25 |   187
xml.ElementTree     591 |   2571   |  3163 |  2574 |  3613 |   25 |  3638
xml.ElementTree     619 |   2567   |  3187 |  2570 |  3589 |   55 |  3644
xml.ElementTree     609 |   2578   |  3188 |  2581 |  3564 |   55 |  3619
lxml                333 |     75   |   409 |    82 |   200 |    0 |   201
lxml                355 |     93   |   448 |    95 |   182 |   32 |   214
lxml                310 |     94   |   404 |    96 |   156 |   56 |   213
------------------------+----------+-------+-------+-------+------+------
name           generate | tostring | total | write | parse | find | total
------------------------+----------+-------+-------+-------+------+------
</pre>
<p>Note that the first &#8220;total&#8221; is &#8220;generate + tostring&#8221; while the second &#8220;total&#8221; is for the 2 parsing related tests (previous 2 columns summed).</p>
<p>My parsing tests are basically &#8220;etree.parse&#8221; and then running &#8220;Element.getchildren()&#8221; 3 times, which is ridiculously simplistic and should probably be ignored.  My writing tests are far more thorough/realistic.</p>
<p>I&#8217;m running Python 2.6.2 with lxml 2.1.5 and libxml2 2.6.32 on Ubuntu 9.04 x86_64.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.schmichael.com/2009/10/14/lxml-vs-elementtree/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Fun with SQLObject and mxDateTime</title>
		<link>http://blog.schmichael.com/2007/11/29/fun-with-sqlobject-and-mxdatetime/</link>
		<comments>http://blog.schmichael.com/2007/11/29/fun-with-sqlobject-and-mxdatetime/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 00:03:23 +0000</pubDate>
		<dc:creator>Michael Schurter</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[cherrypy]]></category>
		<category><![CDATA[mxdatetime]]></category>
		<category><![CDATA[sqlobject]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://michael.susens-schurter.com/blog/2007/11/29/fun-with-sqlobject-and-mxdatetime/</guid>
		<description><![CDATA[I&#8217;m working on a small CherryPy web service that among other things saves timestamps to a database. The timestamp is in RFC 3339 format (like 2007-07-31T16:05:00.000-05:00), and I needed to store the timezone. Luckily mxDateTime and SQLObject&#8217;s DateTimeCol both support &#8230; <a href="http://blog.schmichael.com/2007/11/29/fun-with-sqlobject-and-mxdatetime/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a small <a href="http://cherrypy.org">CherryPy</a> web service that among other things saves timestamps to a database.  The timestamp is in <a href="http://www.ietf.org/rfc/rfc3339.txt">RFC 3339</a> format (like <code>2007-07-31T16:05:00.000-05:00</code>), and I needed to store the timezone.</p>
<p>Luckily <a href="http://www.egenix.com/products/python/mxBase/mxDateTime/">mxDateTime</a> and SQLObject&#8217;s DateTimeCol both support full dates with times and time zone.  Unfortunately its not immediately obvious from <a href="http://sqlobject.org/SQLObject.html">SQLObject&#8217;s lackluster documentation</a> how to use mxDateTime instead of Python&#8217;s built-in datetime.</p>
<p>A little searching brought me to a mailing list post about <a href="http://pythonpaste.org/archives/message/20070410.064412.fa195fb7.en.html">how to use mxDateTime by default in SQLObject</a>.  (I don&#8217;t know why the sample code includes the conditional as I would think you&#8217;d want your code to outright fail if you&#8217;re unable to use the datetime library you expect.)</p>
<p>So my model&#8217;s code looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> sqlobject <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
<span style="color: #ff7700;font-weight:bold;">from</span> sqlobject <span style="color: #ff7700;font-weight:bold;">import</span> col
&nbsp;
col.<span style="color: black;">default_datetime_implementation</span> = MXDATETIME_IMPLEMENTATION
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Foo<span style="color: black;">&#40;</span>SQLObject<span style="color: black;">&#41;</span>:
    timestamp = DateTimeCol<span style="color: black;">&#40;</span>default=DateTimeCol.<span style="color: black;">now</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Then my parsing code looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> model
<span style="color: #ff7700;font-weight:bold;">from</span> mx <span style="color: #ff7700;font-weight:bold;">import</span> DateTime
&nbsp;
timestamp = <span style="color: #483d8b;">'2007-07-31T16:05:00.000-05:00'</span>
bar = model.<span style="color: black;">Foo</span><span style="color: black;">&#40;</span>timestamp=DateTime.<span style="color: black;">DateTimeFrom</span><span style="color: black;">&#40;</span>timestamp<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'UTC Timestamp:'</span>, bar.<span style="color: black;">timestamp</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Local Timestamp:'</span>, bar.<span style="color: black;">timestamp</span>.<span style="color: black;">localtime</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Basically once you use the magic line <code>col.default_datetime_implementation = MXDATETIME_IMPLEMENTATION</code>, everything Just Works.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.schmichael.com/2007/11/29/fun-with-sqlobject-and-mxdatetime/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

