<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Py4J Development Blog</title>
	<atom:link href="http://py4j.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://py4j.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 02 Jun 2011 21:09:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='py4j.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Py4J Development Blog</title>
		<link>http://py4j.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://py4j.wordpress.com/osd.xml" title="Py4J Development Blog" />
	<atom:link rel='hub' href='http://py4j.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Py4J 0.7 Released!</title>
		<link>http://py4j.wordpress.com/2011/06/02/py4j-0-7-released/</link>
		<comments>http://py4j.wordpress.com/2011/06/02/py4j-0-7-released/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 21:09:05 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=102</guid>
		<description><![CDATA[Py4J 0.7 has just been released! This release includes the following new features: Major refactoring to support Python 3. Thanks to Alex Grönholm for his patch. The build and setup files have been totally changed. Py4J no longer requires Paver to build and everything is done through ant. The setup.py file only uses distutils. Added [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=102&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Py4J 0.7 has just been released!</p>
<p>This release includes the following new features:</p>
<ul>
<li><strong>Major refactoring to support Python 3</strong>. Thanks to Alex Grönholm for his patch.</li>
<li>The build and setup files have been totally changed. Py4J no longer requires Paver to build and everything is done through ant. The setup.py file only uses distutils.</li>
<li>Added support for Java byte[]: byte array are passed by value and converted to bytearray or bytes.</li>
<li>Py4J package name changed from Py4J to py4j.</li>
<li>Bug fixes in the Python callback server and unicode support.</li>
</ul>
<p>The specific <a href="https://github.com/bartdag/py4j/issues?labels=v0.7&amp;sort=created&amp;direction=desc&amp;state=closed&amp;page=1">issues are discussed on GitHub</a>.</p>
<p>Installing Py4J is one pip away: <em>pip install py4j</em></p>
<p><em></em>Although I&#8217;m still using Py4J everyday, I do not need many more features so future development will be mostly driven by feature requests and bug reports. Feel free to contact me or to write a feature request on GitHub!</p>
<p>Cheers,<br />
Barthélémy</p>
<p>&nbsp;</p>
<p>P.S.</p>
<p>I shall blog soon about a small and hidden feature that I introduced in the Py4J eclipse default server this morning and that made it into 0.7&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=102&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2011/06/02/py4j-0-7-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J 0.7 soon to be released!</title>
		<link>http://py4j.wordpress.com/2011/05/13/py4j-0-7-soon-to-be-released/</link>
		<comments>http://py4j.wordpress.com/2011/05/13/py4j-0-7-soon-to-be-released/#comments</comments>
		<pubDate>Fri, 13 May 2011 16:41:29 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=99</guid>
		<description><![CDATA[Just a quick post to announce that 0.7 will be released as soon as pypi renames the py4j package from Py4J to py4j (note the uppercases in the first name ). The release will introduce compatibility with Python 3.0, thanks to the huge effort of a generous contributor! There are also a few fixes to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=99&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to announce that 0.7 will be released as soon as pypi renames the py4j package from Py4J to py4j (note the uppercases in the first name <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  ). The release will introduce compatibility with Python 3.0, thanks to the huge effort of a generous contributor! There are also a few fixes to bugs reported by users in this version.</p>
<p>Stay tuned!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=99&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2011/05/13/py4j-0-7-soon-to-be-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J 0.6 Released!</title>
		<link>http://py4j.wordpress.com/2011/02/18/py4j-0-6-released/</link>
		<comments>http://py4j.wordpress.com/2011/02/18/py4j-0-6-released/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 13:39:22 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=95</guid>
		<description><![CDATA[Py4J 0.6 has just been released. This release includes the following new (and great) features: New exception, Py4JJavaError, that enables Python client programs to access instance of Java exception thrown in the Java client code. Improved Py4J setup: warnings are no longer displayed when installing Py4J. Bug fixes and API additions. In case you did [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=95&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Py4J 0.6 has just been released.</p>
<p>This release includes the following new (and great) features:</p>
<ul>
<li>New exception, Py4JJavaError, that enables Python client programs to access instance of Java exception thrown in the Java client code.</li>
<li>Improved Py4J setup: warnings are no longer displayed when installing Py4J.</li>
<li>Bug fixes and API additions.</li>
</ul>
<p>In case you did not notice, Py4J moved to <a title="Py4J at GitHub" href="https://github.com/bartdag/py4j/">github</a> so contributing is now easier than ever!</p>
<p>I plan to do at least another release (0.7) before Py4J leaves beta and moves to 1.0.</p>
<p><strong>About Py4J<br />
</strong>Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine. Methods are called as if the Java objects resided in the Python interpreter and Java collections can be accessed through standard Python collection methods. Py4J also enables Java programs to call back Python objects. Py4J is distributed under the BSD license.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=95&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2011/02/18/py4j-0-6-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J and Exceptions</title>
		<link>http://py4j.wordpress.com/2011/02/11/py4j-and-exceptions/</link>
		<comments>http://py4j.wordpress.com/2011/02/11/py4j-and-exceptions/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 20:37:30 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=91</guid>
		<description><![CDATA[Py4J 0.6 is almost ready to be released, thanks to Jakub L. Gustak who submitted important bug reports, feature requests, and patches. I have been trying to polish Py4J in the latest releases to make the API more consistent and predictable and the biggest &#8220;feature&#8221; of 0.6 will no doubt be how Py4J treats Exceptions. Currently, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=91&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Py4J 0.6 is almost ready to be released, thanks to Jakub L. Gustak who submitted important bug reports, feature requests, and patches. I have been trying to polish Py4J in the latest releases to make the API more consistent and predictable and the biggest &#8220;feature&#8221; of 0.6 will no doubt be how Py4J treats Exceptions.</p>
<p>Currently, exceptions can be raised in four places: (1) in the Py4J Python code, (2) in the Py4J Java code, (3) in the Java client code, and (4) in the network stack. An exception might be raised in the Py4J code if the client code is not correct, for example, if the client tries to call from Python a Java method that does not exist. Before 0.6, Py4J raised a Py4JError in cases 1,2,3 and a Py4JNetworkError (a subtype of Py4JError) in case 4. Moreover, if the Java exception was raised on the Java side, the Java stack trace was copied, as a string, in the Py4JError.</p>
<p>There are two issues with this approach. First, the client does not have access to the exception instance on the Java side, and this exception may have some important fields and methods that can help the error recovery. Second, it is very difficult for the client to determine at runtime the source of the error.</p>
<p>Starting from 0.6, Py4J will raise three types of exceptions: Py4JNetworkError in case #4, Py4JJavaError in case #3, Py4JError in cases #1 and #2. Py4JNetworkError and Py4JJavaError will be a subtype of Py4JError (so a client can implement a catch all). Py4JJavaError will also have a method that will return the instance of the Java exception and Py4JError will still display the Java stack trace for case #2.</p>
<p>Stay tuned for 0.6!</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=91&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2011/02/11/py4j-and-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J code moves to GitHub</title>
		<link>http://py4j.wordpress.com/2010/11/04/py4j-code-moves-to-github/</link>
		<comments>http://py4j.wordpress.com/2010/11/04/py4j-code-moves-to-github/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 15:12:09 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=88</guid>
		<description><![CDATA[It is now official. Py4J code has been moved to GitHub. The issues have been transferred there too thanks to a handy trac-to-github python script. I will be shutting down the trac instance on SourceForge. The web site, mailing list, and alternate download site will still remain on SourceForge (Py4J has always been available on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=88&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is now official. Py4J code has been moved to <a href="https://github.com/bartdag/py4j">GitHub</a>. The <a href="https://github.com/bartdag/py4j/issues">issues</a> have been transferred there too thanks to a handy <a href="https://gist.github.com/589126">trac-to-github python script</a>. I will be shutting down the trac instance on <a href="http://py4j.sourceforge.net/">SourceForge</a>. The web site, mailing list, and alternate download site will still remain on SourceForge (Py4J has always been available on <a href="http://pypi.python.org/pypi/Py4J/">pypi</a> as well).</p>
<p>The decision to move to a Distributed Version Control System (DVCS) was a no brainer. I tried mercurial for another open source project I work on, <a href="http://bitbucket.org/qualyzer/main/wiki/Home">Qualyzer</a>, and DVCS are clearly superior when it comes to merging and enabling collaboration. The speed boost is also quite welcome (thank you local commit).</p>
<p>The main question was thus: mercurial or git? Actually, the real question was, bitbucket or github? This was not an easy decision, but in the end, the numerous outages and bugs of bitbucket and the higher number of potential collaborators on github convinced me to go with github. In addition, github seems speedier and they developed a tool, <a href="http://hg-git.github.com/">hg-git</a>, that allows mercurial users to work with github repositories.</p>
<p>I must say that I was disappointed with the issue tracker at github which is slightly inferior to the bitbucket tracker (only tags, no milestones, no automatic reference between commit and issues except when closing issues, no complex queries, etc.) and I just learned that their wiki engine was only recently moved to an implicit git repository: I believe bitbucket wikis have always been backed by a mercurial repository&#8230; Anyway, I just wanted to say this because I have read many <a href="http://dev.pocoo.org/~blackbird/github-vs-bitbucket/bitbucket.html">posts bashing bitbucket over github</a> and I did not want to sound like one of them&#8230;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=88&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2010/11/04/py4j-code-moves-to-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J 0.5 Released!</title>
		<link>http://py4j.wordpress.com/2010/10/31/py4j-0-5-released/</link>
		<comments>http://py4j.wordpress.com/2010/10/31/py4j-0-5-released/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 10:08:46 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=85</guid>
		<description><![CDATA[Oh Yeah! It&#8217;s another release of Py4J and there are many interesting features that made their way in: The ability to import packages (e.g., java_import(gateway.jvm, 'java.io.*')) Support for pattern filtering in JavaGateway.help() (e.g., gateway.help(obj,'get*Foo*Bar')) Support for automatic conversion of Python collections (list, set, dictionary) to Java collections. Two Eclipse features: one embeds the Py4J Java [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=85&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Oh Yeah! It&#8217;s another release of Py4J and there are many interesting features that made their way in:</p>
<ul>
<li>The ability to import packages (e.g., <code>java_import(gateway.jvm, 'java.io.*')</code>)</li>
<li>Support for pattern filtering in JavaGateway.help() (e.g., <code>gateway.help(obj,'get*Foo*Bar')</code>)
<li>Support for automatic conversion of Python collections (list, set, dictionary) to Java collections.</li>
<li>Two Eclipse features: one embeds the Py4J Java library. The other provides a default GatewayServer that is started when Eclipse starts. Both features are available on the new Py4J Eclipse update site: <code>http://py4j.sourceforge.net/py4j_eclipse</code></li>
<li>New module decomposition: there are no more mandatory circular dependencies among modules.</li>
<li>Have a look at the <a href="http://sourceforge.net/apps/trac/py4j/milestone/0.5%20-%20Polishing">Trac 0.5 milestone</a> for a detailed description of the issues fixed in this release!</li>
</ul>
<p>This feature marks the return to a predictable and regular schedule: one release every two months. I am particularly proud that I could make this release given my crazy and stressful schedule these last days <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I should restate that I use Py4J every day since version 0.4 and most of the features that made it painful to use are now completed. The next release will focus on source code cleanup (be more pythonic), a few corner case features that are difficult to implement but that will make Py4J a killer application, and better unit test organisation. As usual, comments are welcome and if there is any feature you would like to see in the next release, now would be a good time to make your voice heard!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=85&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2010/10/31/py4j-0-5-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J 0.4 released</title>
		<link>http://py4j.wordpress.com/2010/09/19/py4j-0-4-released/</link>
		<comments>http://py4j.wordpress.com/2010/09/19/py4j-0-4-released/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 14:34:30 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=80</guid>
		<description><![CDATA[Py4J 0.4 has just been released! New features include: Polishing of existing features: fields can be set (not just read), None is accepted as a method parameter, methods are sorted alhabetically in gateway.help(), etc. Java Exception Stack Trace are now propagated to Python side. Changed interfaces member in Callback classes to implements. Internal refactoring to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=80&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Py4J 0.4 has just been released! New features include:</p>
<div id="_mcePaste">
<ul>
<li>Polishing of existing features: fields can be set (not just read), None is accepted as a method parameter, methods are sorted alhabetically in gateway.help(), etc.</li>
<li>Java Exception Stack Trace are now propagated to Python side.</li>
<li>Changed interfaces member in Callback classes to implements.</li>
<li>Internal refactoring to adopt clearer terminology and make Py4J protocol extensible.</li>
<li>Many bug fixes: most are related to the callback feature.</li>
</ul>
</div>
<p>Since the beginning of Py4J, I have been trying to release early and  often and to release on a regular basis (2 months). Unfortunately,  because I have been extremely busy during the summer (hey, we moved to our new condo!), I have made the  mistake of pushing back the release date in the hope that it would give  me time to complete all the tickets for 0.4.</p>
<p>This is <strong>not</strong> how it should work. The next release is due in 6 weeks  and even if there is only one new bug fix or one new feature, it will be  released at that date.</p>
<p>In the meantime, you should go ahead and <a href="http://py4j.sourceforge.net/download.html">download Py4J</a>!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=80&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2010/09/19/py4j-0-4-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J 0.4 Release Delayed</title>
		<link>http://py4j.wordpress.com/2010/07/07/py4j-0-4-release-delayed/</link>
		<comments>http://py4j.wordpress.com/2010/07/07/py4j-0-4-release-delayed/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 18:43:17 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=76</guid>
		<description><![CDATA[Unfortunately, I must delay the 0.4 release because I have other priorities for now. The tentative release date is by the end of August. The SVN head, available at https://py4j.svn.sourceforge.net/svnroot/py4j/trunk, contains the most important new features and bug fixes of 0.4 so do not hesitate to use the code from the repository. In fact, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=76&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, I must delay the 0.4 release because I have other priorities for now. The tentative release date is by the end of August.</p>
<p>The SVN head, available at <tt>https://py4j.svn.sourceforge.net/svnroot/py4j/trunk</tt>, contains the most important new features and bug fixes of 0.4 so do not hesitate to use the code from the repository. In fact, I use this code every day for the tool I&#8217;m developing for my Ph.D.</p>
<p>As always, comments are welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=76&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2010/07/07/py4j-0-4-release-delayed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Py4J 0.3 is now available!</title>
		<link>http://py4j.wordpress.com/2010/04/27/py4j-0-3-is-now-available/</link>
		<comments>http://py4j.wordpress.com/2010/04/27/py4j-0-3-is-now-available/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 20:43:02 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=71</guid>
		<description><![CDATA[I just released Py4J 0.3, a major milestone. This release adds support for more Java collections such as array and set, but more importantly, it enables Java objects to call Python objects that implements a Java interface. While working on Py4J, I constantly pushed the hard features and the nasty bug fixes to milestone 0.3. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=71&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just released Py4J 0.3, a major milestone. This release adds <a title="Py4J Support for Java Collections" href="http://py4j.sourceforge.net/advanced_topics.html#accessing-java-collections-and-arrays-from-python">support for more Java collections</a> such as array and set, but more importantly, it enables <a title="Py4J callback support" href="http://py4j.sourceforge.net/advanced_topics.html#enabling-java-objects-to-call-python-objects-callback">Java objects to call Python objects</a> that implements a Java interface.</p>
<p>While working on Py4J, I constantly pushed the hard features and the nasty bug fixes to milestone 0.3. Let&#8217;s just say that I&#8217;m happy this release is now behind me and I am promoting Py4J to beta because all major features are now implemented and relatively well tested.</p>
<p>Enabling callback required a major rearchitecture of Py4J internals and I had to implement a multi-threaded and multi-socket RMI-like server on both the Python and the Java sides. Fortunately, this is not the first time I am involved in shady businesses like this (I remember a graduate software fault tolerance course where I created a redundant framework relying on an orgy of sockets, threads, and processes).</p>
<p>Another area that caused me some worries was the garbage collection in Python and in Java. It took me dozen of hours to reach a good level of understanding of Python handling of garbage collection, weak references, and circular references. I would have preferred to have spent these hours on Team Fortress 2, but in the end, I am glad I learned something valuable.</p>
<p>Getting this kind of code to work is hard and I expect it will take a few more releases to polish it and to uncover bugs, but I believe the time I took to design the new architecture on paper was worth it and the initial tests are green <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Now, stop reading this post and go <a title="Download Py4J" href="http://pypi.python.org/pypi/Py4J/0.3">download Py4J 0.3</a>!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=71&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2010/04/27/py4j-0-3-is-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
		<item>
		<title>Memory Management and Circular References in Python – Part 3</title>
		<link>http://py4j.wordpress.com/2010/03/27/memory-management-and-circular-references-in-python-%e2%80%93-part-3/</link>
		<comments>http://py4j.wordpress.com/2010/03/27/memory-management-and-circular-references-in-python-%e2%80%93-part-3/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 12:40:03 +0000</pubDate>
		<dc:creator>Barthelemy Dagenais</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://py4j.wordpress.com/?p=62</guid>
		<description><![CDATA[In the previous post, we saw that finalizers are difficult to write in the presence of circular references, even when using weak references to hold the finalizer callback. The main issue is that if object A&#8217;s finalizer is held by object A, and object A has a circular reference with object B, the finalizer will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=62&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://py4j.wordpress.com/2010/03/15/memory-management-and-circular-references-in-python-%E2%80%93-part-2/">previous post</a>, we saw that finalizers are difficult to write in the presence of circular references, even when using weak references to hold the finalizer callback. The main issue is that if object A&#8217;s finalizer is held by object A, and object A has a circular reference with object B, the finalizer will never get invoked because both objects are removed before the finalizer has a change to be invoked.</p>
<p>There are two strategies to work around this issue: one is to save the finalizers in an external object that does not belong to a cycle with object A, the other is to remove the circular reference with object B. This is essentially what JavaObject1 and JavaObject2 do in the next code snippet:</p>
<pre style="font-size:120%;color:#000000;background:#ffffff;">finalizers <span style="color:#808030;">=</span> <span style="color:#808030;">[</span><span style="color:#808030;">]</span>

<span style="color:#800000;font-weight:bold;">class</span> JavaObject1<span style="color:#808030;">(</span>object<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
    <span style="color:#800000;font-weight:bold;">def</span> <span style="color:#e34adc;">__init__</span><span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> <span style="color:#e34adc;">id</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        self<span style="color:#808030;">.</span>_id <span style="color:#808030;">=</span> <span style="color:#e34adc;">id</span>
        self<span style="color:#808030;">.</span>_methods <span style="color:#808030;">=</span> <span style="color:#800080;">{</span><span style="color:#800080;">}</span>
        finalizers<span style="color:#808030;">.</span>append<span style="color:#808030;">(</span>weakref<span style="color:#808030;">.</span>ref<span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> <span style="color:#e34adc;">lambda</span> wr <span style="color:#808030;">:</span> inc1<span style="color:#808030;">(</span><span style="color:#808030;">)</span><span style="color:#808030;">)</span><span style="color:#808030;">)</span>

    <span style="color:#800000;font-weight:bold;">def</span> <span style="color:#e34adc;">__getattr__</span><span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> name<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        <span style="color:#800000;font-weight:bold;">if</span> name <span style="color:#800000;font-weight:bold;">not</span> <span style="color:#800000;font-weight:bold;">in</span> self<span style="color:#808030;">.</span>_methods<span style="color:#808030;">:</span>
            self<span style="color:#808030;">.</span>_methods<span style="color:#808030;">[</span>name<span style="color:#808030;">]</span> <span style="color:#808030;">=</span> JavaMember<span style="color:#808030;">(</span>name<span style="color:#808030;">,</span> self<span style="color:#808030;">)</span>
        <span style="color:#800000;font-weight:bold;">return</span> self<span style="color:#808030;">.</span>_methods<span style="color:#808030;">[</span>name<span style="color:#808030;">]</span>

<span style="color:#800000;font-weight:bold;">class</span> JavaObject2<span style="color:#808030;">(</span>object<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
    <span style="color:#800000;font-weight:bold;">def</span> <span style="color:#e34adc;">__init__</span><span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> <span style="color:#e34adc;">id</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        self<span style="color:#808030;">.</span>_id <span style="color:#808030;">=</span> <span style="color:#e34adc;">id</span>
        self<span style="color:#808030;">.</span>_wr <span style="color:#808030;">=</span> weakref<span style="color:#808030;">.</span>ref<span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> <span style="color:#e34adc;">lambda</span> wr <span style="color:#808030;">:</span> inc2<span style="color:#808030;">(</span><span style="color:#808030;">)</span><span style="color:#808030;">)</span>  

    <span style="color:#800000;font-weight:bold;">def</span> <span style="color:#e34adc;">__getattr__</span><span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> name<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        <span style="color:#800000;font-weight:bold;">return</span> JavaMember<span style="color:#808030;">(</span>name<span style="color:#808030;">,</span> self<span style="color:#808030;">)</span>

<span style="color:#800000;font-weight:bold;">class</span> JavaMember<span style="color:#808030;">(</span>object<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
    <span style="color:#800000;font-weight:bold;">def</span> <span style="color:#e34adc;">__init__</span><span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> name<span style="color:#808030;">,</span> container<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        self<span style="color:#808030;">.</span>name <span style="color:#808030;">=</span> name
        self<span style="color:#808030;">.</span>container <span style="color:#808030;">=</span> container

    <span style="color:#800000;font-weight:bold;">def</span> <span style="color:#e34adc;">__call__</span><span style="color:#808030;">(</span>self<span style="color:#808030;">,</span> <span style="color:#808030;">*</span>args<span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        j <span style="color:#808030;">=</span> <span style="color:#008c00;">0</span>
        <span style="color:#800000;font-weight:bold;">for</span> i <span style="color:#800000;font-weight:bold;">in</span> <span style="color:#e34adc;">xrange</span><span style="color:#808030;">(</span><span style="color:#008c00;">1</span><span style="color:#808030;">,</span> <span style="color:#008c00;">10</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
            j <span style="color:#808030;">+</span><span style="color:#808030;">=</span> i
</pre>
<p>As we can see, the weak reference/finalizer in JavaObject1 is held by the global variable finalizers. JavaObject2 is no longer part of a cycle because it creates a new JavaMember every time a member is requested. The JavaMember still refers to the JavaObject2 instance to prevent the eager garbage collection of the JavaObject2 instance discussed at the <a href="http://py4j.wordpress.com/2010/03/15/memory-management-and-circular-references-in-python-%E2%80%93-part-2/">beginning of the last post</a>. If we try to test our new implementations, we obtain these results:</p>
<pre style="font-size:120%;color:#000000;background:#ffffff;"><span style="color:#800000;font-weight:bold;">def</span> m1<span style="color:#808030;">(</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
    <span style="color:#800000;font-weight:bold;">for</span> j <span style="color:#800000;font-weight:bold;">in</span> <span style="color:#e34adc;">xrange</span><span style="color:#808030;">(</span><span style="color:#008c00;">0</span><span style="color:#808030;">,</span> <span style="color:#008c00;">100</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        java_object <span style="color:#808030;">=</span> JavaObject1<span style="color:#808030;">(</span><span style="color:#0000e6;">'o'</span> <span style="color:#808030;">+</span> <span style="color:#e34adc;">str</span><span style="color:#808030;">(</span>j<span style="color:#808030;">)</span><span style="color:#808030;">)</span>
        <span style="color:#800000;font-weight:bold;">for</span> i <span style="color:#800000;font-weight:bold;">in</span> <span style="color:#e34adc;">xrange</span><span style="color:#808030;">(</span><span style="color:#008c00;">10000</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
            java_object<span style="color:#808030;">.</span>method1<span style="color:#808030;">(</span><span style="color:#808030;">)</span>

<span style="color:#800000;font-weight:bold;">def</span> m2<span style="color:#808030;">(</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
    <span style="color:#800000;font-weight:bold;">for</span> j <span style="color:#800000;font-weight:bold;">in</span> <span style="color:#e34adc;">xrange</span><span style="color:#808030;">(</span><span style="color:#008c00;">0</span><span style="color:#808030;">,</span> <span style="color:#008c00;">100</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
        java_object <span style="color:#808030;">=</span> JavaObject2<span style="color:#808030;">(</span><span style="color:#0000e6;">'o'</span> <span style="color:#808030;">+</span> <span style="color:#e34adc;">str</span><span style="color:#808030;">(</span>j<span style="color:#808030;">)</span><span style="color:#808030;">)</span>
        <span style="color:#800000;font-weight:bold;">for</span> i <span style="color:#800000;font-weight:bold;">in</span> <span style="color:#e34adc;">xrange</span><span style="color:#808030;">(</span><span style="color:#008c00;">10000</span><span style="color:#808030;">)</span><span style="color:#808030;">:</span>
            java_object<span style="color:#808030;">.</span>method1<span style="color:#808030;">(</span><span style="color:#808030;">)</span>

<span style="color:#800000;font-weight:bold;">if</span> <span style="color:#e34adc;">__name__</span> <span style="color:#808030;">=</span><span style="color:#808030;">=</span> <span style="color:#0000e6;">'__main__'</span><span style="color:#808030;">:</span>
    timer<span style="color:#808030;">(</span>m1<span style="color:#808030;">,</span><span style="color:#0000e6;">'With JavaObject1: '</span><span style="color:#808030;">)</span>
    timer<span style="color:#808030;">(</span>m2<span style="color:#808030;">,</span><span style="color:#0000e6;">'With JavaObject2: '</span><span style="color:#808030;">)</span>

<span style="color:#808030;">.</span><span style="color:#808030;">.</span><span style="color:#808030;">.</span>

With JavaObject1<span style="color:#808030;">:</span> <span style="color:#008000;">1.83600997925</span>
acc1<span style="color:#808030;">:</span><span style="color:#008c00;">47</span>
acc2<span style="color:#808030;">:</span><span style="color:#008c00;">0</span>
With JavaObject2<span style="color:#808030;">:</span> <span style="color:#008000;">2.38709688187</span>
acc1<span style="color:#808030;">:</span><span style="color:#008c00;">47</span>
acc2<span style="color:#808030;">:</span><span style="color:#008c00;">100</span>
</pre>
<p><strong>REMINDER</strong>: the float number is the time it took to make 1 million method calls (1oo instances X 10 000 calls), the number beside acc1 indicates how many times a finalizer of a JavaObject1 instance was called (max 100), and acc2 indicates how many times a finalizer of a JavaObject2 instance was called.</p>
<p>First, we can see that JavaObject1 is performing a little better than JavaObject2 because method objects are cached and do not need to be instantiated at every call. Second, we can see that not all finalizers of JavaObject1 instances are called. Why?</p>
<p>Well, the answer lies in the garbage collection strategies used by CPython. Roughly, when there is no circular dependency, CPython uses a reference counting strategy: when the last reference to an object is deleted, the object is immediately garbaged collected (hence the perfect acc2 score for JavaObject2). But when there is a circular dependency, CPython uses a mark and sweep strategy which is only executed once in a while. In other words, the Python interpreter has to stop the program execution, inspect the objects, and clean the objects. The frequency of the garbage collection can be set using the <a href="http://docs.python.org/library/gc.html#gc.set_threshold">gc module</a>.</p>
<p>In the previous example, because the program did not execute long enough (more precisely, because the number of allocations/deallocations did not reach the gc thresholds), some objects were never collected before the end of the program. If instead we explicitly invoke the garbage collector, we see that now all finalizers are invoked:</p>
<pre style="font-size:120%;color:#000000;background:#ffffff;"><span style="color:#800000;font-weight:bold;">if</span> <span style="color:#e34adc;">__name__</span> <span style="color:#808030;">=</span><span style="color:#808030;">=</span> <span style="color:#0000e6;">'__main__'</span><span style="color:#808030;">:</span>
    timer<span style="color:#808030;">(</span>m1<span style="color:#808030;">,</span><span style="color:#0000e6;">'With JavaObject1: '</span><span style="color:#808030;">)</span>
    timer<span style="color:#808030;">(</span>m2<span style="color:#808030;">,</span><span style="color:#0000e6;">'With JavaObject2: '</span><span style="color:#808030;">)</span>

    <span style="color:#800000;font-weight:bold;">print</span><span style="color:#808030;">(</span><span style="color:#0000e6;">'Running GC'</span><span style="color:#808030;">)</span>
    gc<span style="color:#808030;">.</span>collect<span style="color:#808030;">(</span><span style="color:#808030;">)</span>
    <span style="color:#800000;font-weight:bold;">print</span><span style="color:#808030;">(</span><span style="color:#0000e6;">'acc1:'</span> <span style="color:#808030;">+</span> <span style="color:#e34adc;">str</span><span style="color:#808030;">(</span>accumulator1<span style="color:#808030;">)</span><span style="color:#808030;">)</span>
    <span style="color:#800000;font-weight:bold;">print</span><span style="color:#808030;">(</span><span style="color:#0000e6;">'acc2:'</span> <span style="color:#808030;">+</span> <span style="color:#e34adc;">str</span><span style="color:#808030;">(</span>accumulator2<span style="color:#808030;">)</span><span style="color:#808030;">)</span>

<span style="color:#808030;">.</span><span style="color:#808030;">.</span><span style="color:#808030;">.</span>

With JavaObject1<span style="color:#808030;">:</span> <span style="color:#008000;">1.83600997925</span>
acc1<span style="color:#808030;">:</span><span style="color:#008c00;">47</span>
acc2<span style="color:#808030;">:</span><span style="color:#008c00;">0</span>
With JavaObject2<span style="color:#808030;">:</span> <span style="color:#008000;">2.38709688187</span>
acc1<span style="color:#808030;">:</span><span style="color:#008c00;">47</span>
acc2<span style="color:#808030;">:</span><span style="color:#008c00;">100</span>
Running GC
acc1<span style="color:#808030;">:</span><span style="color:#008c00;">100</span>
acc2<span style="color:#808030;">:</span><span style="color:#008c00;">100</span>
</pre>
<p>The next post will provide a summary of the lessons learned!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/py4j.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/py4j.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/py4j.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/py4j.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/py4j.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/py4j.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/py4j.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/py4j.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=py4j.wordpress.com&amp;blog=12077018&amp;post=62&amp;subd=py4j&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://py4j.wordpress.com/2010/03/27/memory-management-and-circular-references-in-python-%e2%80%93-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc7387cedba30b9a3d12792084b4b4a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">barthe</media:title>
		</media:content>
	</item>
	</channel>
</rss>
