<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-36545422</atom:id><lastBuildDate>Thu, 11 Mar 2010 19:52:57 +0000</lastBuildDate><title>Front Range Pythoneering</title><description></description><link>http://zyasoft.com/pythoneering/</link><managingEditor>noreply@blogger.com (Jim Baker)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-5056022275001094919</guid><pubDate>Sun, 12 Jul 2009 00:18:00 +0000</pubDate><atom:updated>2009-07-11T18:24:12.281-06:00</atom:updated><title>Trac on Jython - Genshi Support</title><description>(I was going to add this as a comment to &lt;a href="http://blog.nixdev.net/2008/09/12/trac-jython/"&gt;NixDev Open Source Blog&lt;/a&gt; but the commenting system for that blog is currently broken. So here's my response, and maybe it will get me to start blogging here again too.)&lt;br /&gt;&lt;br /&gt;There has been less interest in Genshi from Jython development as of late, probably because Mako is a very good alternative for Turbogears 2 and Pylons. But you need Genshi for Trac, so here's what you might do:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;expat. Jython 2.5 has an implementation of expat (Lib/xml/parses/expat.py) that wraps SAX sufficiently that all of the unit tests for ElementTree pass. The only problem is that it's somewhat slow, since the wrapper is in Python. I would see that as a starting point to selective rewriting in Java, which is much easier to do in Jython than in CPython. Perhaps with just a little more emulation work it will also work with Genshi?&lt;br /&gt;&lt;br /&gt;&lt;li&gt;AST. Jython 2.5 implements the standard _ast and ast (the latter actually part of 2.6, but we needed it!) modules; we do not have any support for the older compiler module. I don't know the status of &lt;a href="http://genshi.edgewall.org/changeset/31"&gt;changeset 31&lt;/a&gt; to support AST, but if it has been incorporated, or can be, we can work with this part then.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;CPython bytecode. Lastly Jython 2.5 implements a CPython bytecode VM. This has been tested by compiling the entire regression test suite into CPython byte code (with CPython, we don't yet have a compiler for this path!), and except for some cases around code introspection and minor differences in floating point representation (which is an artifact of using CPython for the compilation process), it passes. So you should be able to generate bytecode and just have it run. Look at Lib/test/test_pbcvm.py for some details here.&lt;br /&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Good luck! Feel free to ask any questions on the jython-dev mailing list or #jython on IRC.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-5056022275001094919?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2009/07/trac-on-jython-genshi-support.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-5691157867150105730</guid><pubDate>Tue, 24 Jun 2008 16:59:00 +0000</pubDate><atom:updated>2008-06-24T11:10:08.973-06:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>jython</category><category domain='http://www.blogger.com/atom/ns#'>2.5</category><title>Flipping the 2.5 Bit for Jython</title><description>Something worth pointing out; as of 8 AM this morning (MDT) in rev 4748, Frank Wierzbicki flipped the bits and pronounced this about the ASM branch:&lt;br /&gt;&lt;br /&gt;jbaker:~/jythondev/asm jbaker$ dist/bin/jython&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Jython 2.5a0+&lt;/span&gt; (asm:4750, Jun 24 2008, 10:56:16)&lt;br /&gt;[Java HotSpot(TM) Client VM ("Apple Computer, Inc.")] on java1.5.0_13&lt;br /&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;Yesterday there were easily the most commits we have seen in the Jython project. The real threshold was reached when we incorporated the UTF-16 and new-style exception branches into this branch, fixed the grammar to support most incremental parses, while repointing the standard library to CPythonLib 2.5. Along with a flurry of other fixes!&lt;br /&gt;&lt;br /&gt;There's a lot more to go, but this should be an encouraging sign for everyone interested in Jython!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-5691157867150105730?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2008/06/flipping-25-bit-for-jython.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-176568082867459923</guid><pubDate>Tue, 24 Jun 2008 16:13:00 +0000</pubDate><atom:updated>2008-06-24T10:49:52.293-06:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>utf-16</category><category domain='http://www.blogger.com/atom/ns#'>jython</category><category domain='http://www.blogger.com/atom/ns#'>2.5</category><category domain='http://www.blogger.com/atom/ns#'>unicode</category><category domain='http://www.blogger.com/atom/ns#'>re</category><title>Adopting UTF-16</title><description>Jython 2.5 standardizes on Java 5 as the base version for its implementation. Jython has always mapped both &lt;cite&gt;unicode&lt;/cite&gt; and &lt;cite&gt;str&lt;/cite&gt; types to &lt;cite&gt;java.lang.String&lt;/cite&gt;, but the semantics of &lt;cite&gt;String&lt;/cite&gt; changed as of Java 5. Instead of encoding characters as UCS-2, that is just the basic multlingual plane of 65536 code points, Java - like .Net - adopted the UTF-16 encoding. UTF-16 can represent all 1114112 Unicode code points (&lt;cite&gt;U+0&lt;/cite&gt; to &lt;cite&gt;U+10FFFF&lt;/cite&gt;), except for isolated surrogates (&lt;cite&gt;U+D800&lt;/cite&gt; to &lt;cite&gt;U+DFFF&lt;/cite&gt;). These surrogates act as escape characters in the UTF-16 encoding.&lt;br /&gt;&lt;br /&gt;This makes things somewhat more complicated, to put it mildly. And this is without even considering combining characters!&lt;br /&gt;&lt;br /&gt;Instead of a simple uniform encoding that we see in the narrow (UCS-2) or wide (UCS-4) builds of CPython, we get a variable-length encoding. And unlike UTF-8, it's usually not too efficient. In addition, we lose the ability to represent the isolated surrogates. Finally, because UTF-16 is so very close to UCS-2, it's prone to bugs.&lt;br /&gt;&lt;br /&gt;Here's the implementation strategy we adopted. In supporting the &lt;cite&gt;unicode&lt;/cite&gt; type with &lt;cite&gt;PyUnicode&lt;/cite&gt;, we first determine if it's in the basic plane or not:&lt;pre class="literal-block"&gt;&lt;br /&gt;private enum Plane {&lt;br /&gt;  UNKNOWN, BASIC, ASTRAL&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private volatile Plane plane = Plane.UNKNOWN;&lt;br /&gt;&lt;br /&gt;public boolean isBasicPlane() {&lt;br /&gt;  if (plane == Plane.BASIC) {&lt;br /&gt;      return true;&lt;br /&gt;  } else if (plane == Plane.UNKNOWN) {&lt;br /&gt;      plane = (string.length() == getCodePointCount()) ?&lt;br /&gt;           Plane.BASIC : Plane.ASTRAL;&lt;br /&gt;  }&lt;br /&gt;  return plane == Plane.BASIC;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;cite&gt;getCodePointCount&lt;/cite&gt; is in turn implemented using &lt;cite&gt;String#codePointCount&lt;/cite&gt;. Like other code point methods, it decodes any surrogate pairs.&lt;/p&gt;&lt;p&gt;String immutability means we can cache the result in the volatile field &lt;cite&gt;plane&lt;/cite&gt;; idempotence of this operation ensures consistency. This allows us to equate code units (&lt;cite&gt;char&lt;/cite&gt;) to code points (&lt;cite&gt;int&lt;/cite&gt;), and use the implementations provided by &lt;cite&gt;PyString&lt;/cite&gt;. As it turns out, this was always done before, the only difference between &lt;cite&gt;str&lt;/cite&gt; and &lt;cite&gt;unicode&lt;/cite&gt; was in the encoding rules.&lt;/p&gt;&lt;p&gt;In the rather rare case it isn't, we read with our &lt;span style="font-style: italic;"&gt;SubsequenceIteratorImpl&lt;/span&gt; (which does a decode and then moves forward in the string, rather useful) or &lt;cite&gt;String#codePointAt&lt;/cite&gt; and write with &lt;cite&gt;StringBuilder#appendCodePoint&lt;/cite&gt; using iterators. A seemingly good alternative would be to use &lt;cite&gt;String#offsetByCodePoints&lt;/cite&gt;. Too bad it &lt;a class="reference" href="http://ed-merks.blogspot.com/2007/02/jdk-bugs-to-fix-or-not-to-fix.html"&gt;doesn't reliably work&lt;/a&gt;. So instead we have our iterator implementations, lots and lots of them. And sometimes crazy stuff like this, seen in the implementation of &lt;cite&gt;PyUnicode#unicode_strip&lt;/cite&gt;:&lt;/p&gt;&lt;pre class="literal-block"&gt;        return new PyUnicode(new ReversedIterator(&lt;br /&gt;        new StripIterator(sep,&lt;br /&gt;            new ReversedIterator(&lt;br /&gt;                new StripIterator(sep,&lt;br /&gt;                    newSubsequenceIterator())))));&lt;br /&gt;&lt;/pre&gt;If &lt;cite&gt;strip&lt;/cite&gt; method was used extensively on strings that weren't in the basic plane, it might make sense to rewrite this to decode to an &lt;cite&gt;int[]&lt;/cite&gt; buffer. But that's not likely to be case.&lt;br /&gt;&lt;br /&gt;That's also the reason we avoid making the basic plane test unless we have to. There are many situations where Unicode can pass in and out of Jython - specifically to/from Java - without us caring about what planes its characters are drawn from. We assume some overhead from boxing with PyUnicode (although HotSpot mitigates the indirection cost), but we don't have to overdo it by computing this test on construction.When comparing this with CPython, we do lose the ability to include isolated surrogate code points in Unicode strings. There are even some unit tests for this case. But ultimately this seemed like an implementation detail like testing ref counting, one certainly not worth time spent supporting.&lt;br /&gt;&lt;br /&gt;It's worth mentioning that one alternative is to create our own representation, much like JRuby. Ruby's strings are mutable, unlike Python's. This forced the issue for the JRuby developers, because Ruby, like Python, needs good string performance. So JRuby uses byte arrays for strings, although they do use UTF-16 encoded, interned &lt;cite&gt;java.lang.String&lt;/cite&gt;'s to uniquely represent symbols (&lt;cite&gt;:xyz&lt;/cite&gt;). Given that symbols are not strings, this works well. Ruby doesn't say anything about the encoding of such strings (ouch!), but JRuby does assume they're UTF-8 encoded when &lt;a class="reference" href="http://headius.blogspot.com/2007/04/paving-road-to-jruby-10-unicode.html"&gt;crossing the boundary with Java&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Supporting widened Unicode means having support for this in regular expressions. The first step was to just widen the SRE engine used by Jython to represent characters with &lt;cite&gt;int&lt;/cite&gt; instead of &lt;cite&gt;short&lt;/cite&gt;. So we always unpack to &lt;cite&gt;int&lt;/cite&gt; in this case; see &lt;cite&gt;strip&lt;/cite&gt; above. This engine is a direct translation of the CPython equivalent: it's a mini-VM, much like the pickle VM, and regexes are compiled to SRE bytecode. In the future, we may consider using JRuby's implementation (Joni, a port of Oniguruma to Java), but the devil is in supporting some specifics to Python. As was seen in the CPython case, it was quite straightforward to just doing the widening.&lt;br /&gt;&lt;br /&gt;At this point, the biggest outstanding issue is backporting the changes to SRE to support wide character classes (aka big character sets), a pickle problem, as well as various bug fixes. A total of four test cases are currently failing in test_re in the asm branch.&lt;br /&gt;&lt;br /&gt;And then that's it, at least until we start doing performance profiling.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-176568082867459923?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2008/06/utf-16-jython-2.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-7684095808267890239</guid><pubDate>Sat, 21 Jun 2008 03:43:00 +0000</pubDate><atom:updated>2008-06-24T12:49:46.651-06:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>jython</category><category domain='http://www.blogger.com/atom/ns#'>2.5</category><title>Realizing Jython 2.5</title><description>&lt;div class="document" id="realizing-jython-2-5"&gt;&lt;a class="reference" href="http://www.jython.org/Project/roadmap.html"&gt;Jython 2.5&lt;/a&gt; is really, finally, unbelievably coming together. This is the next release of Jython, after last summer's 2.2. In a nutshell, we have completed all new language features using an Antlr parser, except for absolute imports. All bytecode generation work, now using an ASM backend, is done. Of course, there are many outstanding bugs. And Python is not just a language; we need to support fully the fact that "batteries are included". But let's look at where we are. Through the prism of what's new in &lt;a class="reference" href="http://www.python.org/doc/2.3/whatsnew/"&gt;2.3&lt;/a&gt;, &lt;a class="reference" href="http://www.python.org/doc/2.4.3/whatsnew/whatsnew24.html"&gt;2.4&lt;/a&gt;, and &lt;a class="reference" href="http://docs.python.org/whatsnew/whatsnew25.html"&gt;2.5&lt;/a&gt;, here's what working:&lt;br /&gt;&lt;ul class="simple"&gt;&lt;li&gt;2.3: sets (PEP 218), generators (255), source code encoding (263), universal newline (278), enumerate (279), logging (282), Boolean (285), distutils (301), new import hooks (302), pickle enhancements (307), extended slices, datetimes, optparse. Still to go: csv, removing a dictionary in builtin that ensures that interned strings don't get GC'ed (pre-2.3 behavior!, it helps to read what's new). Also various string, Unicode, and regex changes are mostly done in a separate utf16 branch that I'm currently in the midst of merging against trunk.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;2.4: unifying long integers (237), generator expressions (289), string.Template (292, but also needs new utf16 work), decorators (318), reverse iteration (322), subprocess module (324), multi-line imports (328), removal of OverflowWarning, min &amp;amp; max with keyword support, sorted. But we still need partial import with sys.modules, and I'm sure some more stuff I forgot. Decimal and -m support are working in student branches, we just need to incorporate.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;2.5: conditional expressions (308), partial functional (309, but we're cheating with a pure-Python version), distutils metadata (314), unified try/except/finally (341), coroutines and other generator functionality (342), with-statement, including contextlib (343), any, all. But we haven't done the exceptions remapping to new-style classes, absolute and relative imports, or all of the context manager support, such as in file. ctypes was a proposed Google Summer of Code project, but apparently PyPy has some work that's 95% the way there; we will talk with them at EuroPython. We need to look into what is necessary to make ElementTree work. sqlite3 depends on ctypes. As I was writing this, I tried out wsgiref; it works and I just committed it to the asm branch. (At some point, we will repoint everything like this to CPythonLib, but for now we are mixing it up as we go. Bear with us!)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Even quit() and exit() now work; I don't know when these oh-so-major features were added. We even now support large string constants. And of course, who can forget our support for the GIL (global interpreter lock) in Jython, something that Tobias Ivarsson, my Google Summer of Code student who is now working on an advanced compiler, added to __future__ as an Easter egg:&lt;br /&gt;&lt;/p&gt;&lt;pre class="literal-block"&gt;&gt;&gt;&gt; from __future__ import GIL&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;(no code object) at line 0&lt;br /&gt;File "&lt;stdin&gt;", line 0&lt;br /&gt;SyntaxError: Never going to happen!&lt;br /&gt;&lt;/pre&gt;I would imagine that's definitive, we go against Java's native threads and compile to Java bytecode. It would be hard to have a GIL, even if we wanted one.&lt;br /&gt;&lt;br /&gt;However, we are just turning the corner. The The Antlr parser in the asm branch currently does not support partial parses, and this breaks not only interactive sessions but doctests. Until this is solved - and &lt;a class="reference" href="http://fwierzbicki.blogspot.com/"&gt;Frank Wierzbicki&lt;/a&gt; is working like &lt;a class="reference" href="http://twitter.com/fwierzbicki"&gt;mad&lt;/a&gt; on this - we can't merge this branch onto trunk. But that should happen very soon.With few exceptions, we simply go against the standard Python unit tests. Straightforward, cunning, or devious, we have labored against these unit tests. And in others, we have used Python as our foil: we support the same 2.5 AST parse tree, and we know this by comparing our parses with CPython's for all of the standard library - including those unit tests.&lt;br /&gt;&lt;br /&gt;There's a lot more going on. I can't say enough about the work done by &lt;a class="reference" href="http://cnapalm.blogspot.com/"&gt;Charlie Groves&lt;/a&gt;, &lt;a class="reference" href="http://dunderboss.blogspot.com/"&gt;Philip Jenvey&lt;/a&gt;, &lt;a class="reference" href="http://www.xhaus.com/alan/python/index.html"&gt;Alan Kennedy&lt;/a&gt;, &lt;a class="reference" href="http://web.sabi.net/nriley/"&gt;Nicholas Riley&lt;/a&gt;, and others to make this happen.  &lt;a class="reference" href="http://blog.leosoto.com/"&gt;Leo Soto&lt;/a&gt;, my other GSoC student, is making amazing progress on &lt;a class="reference" href="http://dojstatus.leosoto.com/"&gt;supporting Django on Jython&lt;/a&gt;, while finding and fixing bugs in Jython itself. Supporting Django forces us to find those gaps in compatibility. Similar efforts are going on with Pylons, TurboGears 2 (Ariane Paola, GSoC), and Zope (&lt;a class="reference" href="https://launchpad.net/%7Ecodingmaster"&gt;Georgy Berdyshev&lt;/a&gt;, GSoC). I'm also working on greenlet/Stackless support and involved in a collaboration with &lt;a class="reference" href="http://ece.colorado.edu/%7Esiek/"&gt;Jeremy Siek&lt;/a&gt; and Joe Angell at the University of Colorado to add &lt;a class="reference" href="http://ece.colorado.edu/%7Esiek/dls08igtlc.pdf"&gt;gradual typing&lt;/a&gt; (yes types! but only when you want to) to Jython. We have a T2000 contributed by Sun to let us see how much concurrency - in this case 32 hardware threads, 64 GB of memory - Jython can take advantage of. And so on.&lt;br /&gt;&lt;br /&gt;Back to work!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Updates - 2008-06-24&lt;/span&gt;: we have support for new-style exceptions, the parser is now usable (but there are a couple of bugs left there), and Unicode support has been updated to UTF-16. See this posting, &lt;a href="http://zyasoft.com/pythoneering/2008/06/flipping-25-bit-for-jython.html"&gt;Flipping the 2.5 Bit for Jython&lt;/a&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-7684095808267890239?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2008/06/realizing-jython-25.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>6</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-4670751183434309138</guid><pubDate>Fri, 04 Jan 2008 04:59:00 +0000</pubDate><atom:updated>2008-06-24T13:02:15.206-06:00</atom:updated><title>Django on Jython: Minding the Gap</title><description>&lt;h2 id="head-8fbbb7c7d944ae3ef8c1b25b14973ac30ab623f3"&gt;Summary&lt;br /&gt;&lt;/h2&gt; &lt;span class="anchor" id="line-4"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-5"&gt;&lt;/span&gt;&lt;p class="line874"&gt;The most important thing to know about Django on Jython is that we are almost there, and with clean code. End-to-end functionality is demonstrated by the admin tool running in full CRUD, along with a substantial number of unit tests and syncdb. But this has been achieved by so far requiring only 6 lines of code in changes to Django trunk. (There will be more, however, see below.) &lt;span class="anchor" id="line-6"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-7"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line867"&gt; &lt;/p&gt;&lt;h2 id="head-2e3a2553c8f5122907bb333b9ce6c0d3bbc08843"&gt;Running on Jython&lt;/h2&gt; &lt;span class="anchor" id="line-8"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-9"&gt;&lt;/span&gt;&lt;p class="line874"&gt;To run Django on Jython, with a PostgreSQL backend, the following steps are necessary: &lt;span class="anchor" id="line-10"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-11"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p class="line862"&gt;Use the &lt;a class="https" href="https://jython.svn.sourceforge.net/svnroot/jython/branches/modern/"&gt;Modern branch&lt;/a&gt; of Jython. This consolidated the &lt;a href="http://wiki.python.org/jython/DjangoOnJython"&gt;bugs, workarounds, and patches&lt;/a&gt; of numerous people - plus a bunch more - in a stable, almost-ready-to-be-merged-into-trunk version of Jython. The most important aspect is that we have tried to make Jython conform more to CPython, using Django as our guide, although there are some gaps - especially if Django already had incorporated fixes. Our driving goal is to converge on these gaps over time. Please note that is intended to be stable, performant code. &lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;Use the Django trunk (tested with rev 6992, later should be OK too). &lt;span class="anchor" id="line-14"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-15"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="gap"&gt;&lt;p class="line862"&gt;Apply these two patches, &lt;a class="https" href="https://jython.svn.sourceforge.net/svnroot/jython/trunk/sandbox/jbaker/django/dispatch/robustapply.py"&gt;django.dispatch.robustapply&lt;/a&gt; (&lt;a class="https" href="https://hg.leosoto.com/django.jythonport/rev/bb2b9048ed14f72e99c5c133c7ecaaeb0a5c425c"&gt;diff&lt;/a&gt;) and &lt;a class="https" href="https://jython.svn.sourceforge.net/svnroot/jython/trunk/sandbox/jbaker/django/views/debug.py"&gt;django.views.debug&lt;/a&gt; (&lt;a class="https" href="https://hg.leosoto.com/django.jythonport/rev/663bcf5efc31409899fcdc10009bc92df3e1f6b9"&gt;diff&lt;/a&gt;) due to Leo Soto. I would imagine these will be in Django trunk soon. &lt;span class="anchor" id="line-16"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-17"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;Copy these three files from CPythonLib to Lib: gettext.py, locale.py, optparse.py. Please note that these files are only partially working on Jython, that's why they haven't been promoted yet (gettext.py actually works, as verified by test_gettext.py, but depends on still failing locale.py). But they are very close, and they appear to be fine for Django. Certainly fine for this round of development! &lt;span class="anchor" id="line-18"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-19"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="gap"&gt;&lt;p class="line862"&gt;Use the database backend &lt;a class="https" href="https://jython.svn.sourceforge.net/svnroot/jython/trunk/sandbox/jbaker/django/db/backends/postgresql_zxjdbc/"&gt;zxjdbc_postgresql&lt;/a&gt;, which was contributed by Leo Soto. Frank Wierzbicki has an experimental backend for MySQL, this should be incorporated soon. &lt;span class="anchor" id="line-20"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-21"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="line867"&gt; &lt;/p&gt;&lt;h2 id="head-3b7c8bf33a146c28297661cea835665d074d7087"&gt;Status&lt;/h2&gt; &lt;span class="anchor" id="line-22"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-23"&gt;&lt;/span&gt;&lt;p class="line874"&gt;Here's what works: &lt;span class="anchor" id="line-24"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-25"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line862"&gt;syncdb and the very cool Django admin run; many unit tests pass. You can run with internationalization enabled. You do need to run the dev server with --noreload for now. We need to document here how to run with &lt;a class="http" href="http://www.xhaus.com/modjy/"&gt;modjy&lt;/a&gt;, which is Alan Kennedy's servlet container for WSGI apps. &lt;span class="anchor" id="line-26"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-27"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line874"&gt;In running the model unit tests, here are the things we seem to be missing, accounting for most of the approximately 75 failures: &lt;span class="anchor" id="line-28"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-29"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p class="line862"&gt;Many doctests are fragile, because they depend on the dict traversal ordering; in Jython, this is different that CPython, and if we adopt &lt;tt&gt;ConcurrentHashMap&lt;/tt&gt;, it's not even repeatable. This would seem to be a pervasive bug in Django. &lt;span class="anchor" id="line-30"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-31"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;&lt;p class="line862"&gt;We still have some encoding problems, again seen in doctests. An example where output is expected to be lower case hex, not upper case. I fixed the problem in &lt;tt&gt;PyUnicode&lt;/tt&gt;, but there are more places. &lt;span class="anchor" id="line-32"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-33"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;&lt;p class="line862"&gt;Problem with the &lt;tt&gt;ManagerDescriptor&lt;/tt&gt; handling, in &lt;tt&gt;django.db.models.manager&lt;/tt&gt;. &lt;span class="anchor" id="line-34"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-35"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;No decorators yet! (But they are coming soon, and are now available experimentally for Jython in the newcompiler work I have been leading.)  &lt;span class="anchor" id="line-36"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-37"&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class="line874"&gt;There may be some other rough categories, we need to look at the failures more systematically. All that doctest noise is certainly annoying! &lt;span class="anchor" id="line-38"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-39"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line867"&gt; &lt;/p&gt;&lt;h2 id="head-24863f234dc1b6e7721b458448e2fc832a7247b2"&gt;Next Steps&lt;/h2&gt; &lt;span class="anchor" id="line-40"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-41"&gt;&lt;/span&gt;&lt;p class="line874"&gt;On the Django front, get more of the unit tests running! &lt;span class="anchor" id="line-42"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-43"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="line874"&gt;Before we can push modern into trunk, the following needs to be done: &lt;span class="anchor" id="line-44"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-45"&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p class="line862"&gt;The test_extcall unit test currently fails. This appears to be a dependency on &lt;tt&gt;dict&lt;/tt&gt; traversal being repeatable, a bad assumption. However, it's a mind bending test. The 2.3 version is particularly problematic because it's not modular at all. Google's GHOP has just produced an improved version for Python 2.6 - we will look at this as a starting point. &lt;span class="anchor" id="line-46"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-47"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;&lt;p class="line862"&gt;Tristan King provided a near complete subset of the functionality for &lt;tt&gt;time.strptime&lt;/tt&gt;, as implemented in &lt;tt&gt;org.python.modules.time.Time&lt;/tt&gt;. This needs to be enhanced. I just tested this, and all unit tests in the CPythonLib version of test_time now pass except for &lt;tt&gt;strptime&lt;/tt&gt; -- specifically the conversion specifier &lt;tt&gt;'%c'&lt;/tt&gt; -- so we can also move to that, and discard our Jython version, when this is completed. That should be soon! &lt;span class="anchor" id="line-48"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-49"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li class="gap"&gt;&lt;p class="line862"&gt;Decide whether we should use &lt;tt&gt;ConcurentHashMap&lt;/tt&gt; or not as the backing hash map for &lt;tt&gt;dict&lt;/tt&gt; and &lt;tt&gt;__dict__&lt;/tt&gt;. CHM introduces creation overhead, but it should prove to be far more scalable on multicore systems. The programming model is also far nicer with respect to Jython.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Updates - 2008-06-24&lt;/span&gt;: I should have put this up a while ago, but &lt;a class="reference" href="http://dojstatus.leosoto.com/"&gt;Django on Jython&lt;/a&gt; is becoming a reality. Most importantly, &lt;a class="reference" href="http://blog.leosoto.com/"&gt;Leo Soto&lt;/a&gt; is working with me through the Google Summer of Code on this project. The modern branch was merged into a trunk earlier this year, and has since been retired. CHM in fact has the right semantics, something I may discuss at a future point. Django has redone the doctest dict literals that were causing problems, and Leo provided a &lt;a href="http://blog.leosoto.com/2008/06/doctests-and-xmlxhtml.html"&gt;general solution when used with XML/XHTML&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-4670751183434309138?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2008/01/django-on-jython-minding-gap.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>23</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-6255584078315038108</guid><pubDate>Sat, 16 Dec 2006 16:17:00 +0000</pubDate><atom:updated>2006-12-16T09:20:40.566-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>jython</category><category domain='http://www.blogger.com/atom/ns#'>python</category><category domain='http://www.blogger.com/atom/ns#'>boulder</category><category domain='http://www.blogger.com/atom/ns#'>concurrency</category><title>Pythoneers Monthly Meeting: This Wednesday, December 20, in Boulder, Colorado</title><description>&lt;div class="moz-text-html" lang="x-unicode"&gt;       &lt;!--[endif]--&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;&lt;b&gt;Important Change: we will be meeting at bivio Software instead of Jill's to better accommodate this month's demos.&lt;/b&gt;&lt;br /&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;This coming Wednesday (December 20) we are having our monthly meeting for the Front Ranage Pythoneers. Come join a lively discussion of Python demos, features, tips &amp; techniques, and directions, both for fun and professional development.&lt;br /&gt;&lt;br /&gt;Here are the meeting specifics:&lt;br /&gt;&lt;/span&gt; &lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;&lt;span style="font-style: italic;"&gt;Date/time&lt;/span&gt;: Wednesday, December 20, 6-8 PM&lt;br /&gt;  &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;&lt;span style="font-style: italic;"&gt;Location&lt;/span&gt;: &lt;a class="external" href="http://www.bivio.biz/"&gt;bivio Software, Inc.&lt;/a&gt;, 28th and Iris. Above Hair Elite in Suite S. &lt;a class="external" href="http://maps.google.com/maps?f=q&amp;hl=en&amp;amp;q=2701+Iris+Ave.,+Boulder+CO&amp;amp;ie=UTF8&amp;z=15&amp;amp;om=1&amp;iwloc=A"&gt;Google Maps link&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;Tom Churchill and Vinny will demo &lt;a href="http://www.churchillnavigation.com/"&gt;Churchill Navigation's&lt;/a&gt; earth-rendering engine (which looks like Google Earth, only apparently even better and faster ;) ). Vinny (their main Python guy) will explain how they built the glue logic (and why they decided against SWIG) and perhaps some of the implications of using Python as a scripting language in a real-time (60 fps) environment, and the techniques we employed to keep the graphics pipeline from stalling when making an expensive call into their engine from Python.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;Brian Granger from &lt;a href="http://txcorp.com/"&gt;Tech-X&lt;/a&gt; will help us think more deeply about concurrent Python programming, especially as seen in a new version of &lt;a href="http://ipython.scipy.org/moin/IPython1"&gt;IPython&lt;/a&gt; he has been working on.&lt;br /&gt;  &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;&lt;a href="http://wiki.python.org/moin/BoulderSprint"&gt;BoulderSprint&lt;/a&gt;. Eric Dobbs proposed we adopt Jython, and this looks like we have enough momentum to actually get some useful work done. We will talk about the upcoming sprint to be held on Saturday, January 6.&lt;br /&gt;  &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;We will have food &amp;amp; drink available. Did I mention the &lt;u&gt;free beer&lt;/u&gt;? Hope to see you there.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Helvetica,Arial,sans-serif;"&gt;&lt;br /&gt;- Jim&lt;/span&gt;&lt;!--[if !supportLists]--&gt;&lt;!--[endif]--&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-6255584078315038108?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2006/12/pythoneers-monthly-meeting-this_16.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-116321490211840402</guid><pubDate>Sat, 11 Nov 2006 02:55:00 +0000</pubDate><atom:updated>2006-11-10T20:42:04.826-07:00</atom:updated><title>Pythoneers Monthly Meeting - This Wednesday, Nov 15, in Boulder, Colorado</title><description>This coming Wednesday (November 15) we are having our monthly meeting for the Front Range Pythoneers. &lt;b&gt;Please note, we have moved to &lt;u&gt;Jill's at the St Julien Hotel.&lt;/u&gt;&lt;/b&gt; Come join a lively discussion of Python features, tips &amp;amp; techniques, and directions, both for fun and professional development.&lt;br /&gt;&lt;br /&gt;Here are the meeting specifics:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Status&lt;/i&gt;: &lt;b&gt;Always on&lt;/b&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;Date/time&lt;/i&gt;: Every 3rd Wednesday, 6-8 PM&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;Location&lt;/i&gt;: Jill's at the &lt;a href="http://www.stjulien.com"&gt;St Julien Hotel&lt;/a&gt; (9th and Walnut), the bar area. Jill's combines a beautiful room, great food and beverages, and happy-hour pricing. And for this meeting: your first draft beer (up to 20 people) is &lt;b&gt;free&lt;/b&gt;!&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Hope to see you there.&lt;br /&gt;&lt;br /&gt;We've recently set up a &lt;a href="http://wiki.python.org/moin/FrontRangePythoneers"&gt;wiki&lt;/a&gt;. There, you can help us expand the Guide to Front Range Pythoneering. Or contribute ideas to future &lt;a href="http://wiki.python.org/moin/FrontRangePythoneers"&gt;sprints&lt;/a&gt; and &lt;a href="http://wiki.python.org/moin/BoulderJam"&gt;jams.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-116321490211840402?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2006/11/pythoneers-monthly-meeting-this.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-116284544463044368</guid><pubDate>Mon, 06 Nov 2006 19:08:00 +0000</pubDate><atom:updated>2006-11-06T15:22:09.700-07:00</atom:updated><title>Boulder Sprint: Adding Oracle support to Django</title><description>We had a great turnout on Saturday for the first &lt;a href="http://wiki.python.org/moin/BoulderSprint"&gt;Boulder Sprint&lt;/a&gt; held by the &lt;a href="http://www.fr.co.us.pythoneers.org/"&gt;Front Range Pythoneers&lt;/a&gt;.  Our goal was to provide &lt;a href="http://code.djangoproject.com/ticket/1990"&gt;production-level support of Oracle&lt;/a&gt; in Django 1.0.  I'm glad to report that we made a strong start on this goal.&lt;br /&gt;&lt;br /&gt;Django developer Jacob Kaplan-Moss flew out to Boulder from Lawrence, Kansas, providing us both leadership and guidance into the Django internals. (Next time I hope Jacob doesn't have to fly out the next day on a 6 AM flight!)  From Array Biopharma, we had five developers: Ian Kelly, Matt Boersma, Matt Drew, Michelle Cyr, and Mitch Smith. Eric Dobbs, of Bivio, contributed both the space and his seasoned Python skills. And there was me (Jim Baker). Thanks to everyone for your hard work!&lt;br /&gt;&lt;br /&gt;We worked on a number of key issues for supporting Oracle:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Perhaps most important, Jacob split out Oracle-specific functionality into the Oracle backend, allowing for more modularity. Django uses quite portable code, in conjunction with the Python DB2 API, but Oracle has its peculiarities. Being pragmatic, we had to work through that.&lt;/li&gt;&lt;li&gt;Mapping Django's TextFields to Oracle's CLOBs, not LONGs, which pretty much are deprecated. (Remember Django's origin, we certainly need support for text!) However, supporting CLOBs required some changes: no buffering in the Python layer, just iterate directly over the cursor; explicitly read in data from the LOB reference; prepare the OCI by giving cx_Oracle explicit type information (also necessary for timestamps with greater than one second precision).&lt;/li&gt;&lt;li&gt;Pagination queries. Django's ORM grew out of supporting PostgreSQL, which has OFFSET and LIMIT clauses, useful for the pagination queries often seen in stateless web apps. Oracle actually has quite good support for this type of queries but this fact is not well-known. And frankly it's a bit clumsy to use, requiring doubly nested subqueries. See Oracle guru Tom Kyte's &lt;a href="http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html"&gt;article&lt;/a&gt; in Oracle magazine for more details.  I made some progress on this front, but I still need to integrate it into the new django.db.backends.oracle.OracleQuerySet class added by Jacob.&lt;/li&gt;&lt;li&gt;Test schema support. Oracle uses the concept of "user schema" where other databases might use "database". There's a bit of trickiness in working appropriately with this, especially if there are tablespaces being set up for this test. Eric took the lead on this.&lt;/li&gt;&lt;li&gt;Mitch Smith wrote two gnarly Oracle-specific queries that have almost got&lt;br /&gt;introspection and Django's "inspectdb" command working correctly.&lt;/li&gt;&lt;li&gt;Part of our goal was to get all existing tests to pass from  runtests.py, and we're about 70% there.&lt;/li&gt;&lt;li&gt;Array Biopharma now has their test web app, donuts, running.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And this is just what I saw from my side of the conference room table! We do have a &lt;a href="http://www.flickr.com/photos/tags/bouldersprint/"&gt;photostream&lt;/a&gt; for the Boulder Sprint. Check out Matt B. and Michelle &lt;a href="http://www.flickr.com/photos/67001115@N00/288564942/"&gt;contemplating at the Oracle&lt;/a&gt;. Or Matt B. and Ian &lt;a href="http://www.flickr.com/photos/67001115@N00/288962041/"&gt;asking rhetorically&lt;/a&gt;, "How can we screw up a 3-line function?" There is also a &lt;a href="http://wiki.python.org/moin/BoulderSprint"&gt;wiki&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For the moment, until we get the work integrated in the Django trunk, you can checkout the Boulder Sprint branch here with Subversion:&lt;br /&gt;&lt;br /&gt;svn co http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-116284544463044368?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2006/11/boulder-sprint-adding-oracle-support.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-36545422.post-116231583891324596</guid><pubDate>Tue, 31 Oct 2006 17:30:00 +0000</pubDate><atom:updated>2006-10-31T10:31:37.526-07:00</atom:updated><title>Boulder Sprint this Saturday</title><description>On November 4, 9 AM-6 PM, the Front Range Pythoneers is holding a sprint to complete the support for Oracle in Django. Why might you want to attend? Whether you're interested in Django, portable object-relational mapping code, how to optimize an Oracle execution plan for generated SQL, or just doing some intensive coding in Python, this should be a great opportunity to learn and contribute.&lt;br /&gt;&lt;br /&gt;See the wiki for more details: http://wiki.python.org/moin/BoulderSprint&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/36545422-116231583891324596?l=zyasoft.com%2Fpythoneering%2Findex.html' alt='' /&gt;&lt;/div&gt;</description><link>http://zyasoft.com/pythoneering/2006/10/boulder-sprint-this-saturday_31.html</link><author>noreply@blogger.com (Jim Baker)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item></channel></rss>