<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python: di</title>
	<atom:link href="http://www.friday.com/bbum/2007/08/24/python-di/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.friday.com/bbum/2007/08/24/python-di/</link>
	<description>...so google can index my head.</description>
	<lastBuildDate>Sun, 14 Mar 2010 02:08:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Satoru</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-191806</link>
		<dc:creator>Satoru</dc:creator>
		<pubDate>Sun, 27 Sep 2009 19:01:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-191806</guid>
		<description>Hi.
I don&#039;t know Python well.  Is it possible to code like this without di?


import di

class Debug:
	@classmethod
	def show(self, *val_name):
		print &quot;&quot;,
		print &quot; &quot;.join([m + &quot;:&quot; + str(di.di(id(eval(m)))) for m in val_name])

if __name__ == &#039;__main__&#039;:
	total = 0
	for n in range(10):
		total += n	
		Debug.show(&quot;n&quot;, &quot;total&quot;)</description>
		<content:encoded><![CDATA[<p>Hi.<br />
I don&#8217;t know Python well.  Is it possible to code like this without di?</p>
<p>import di</p>
<p>class Debug:<br />
	@classmethod<br />
	def show(self, *val_name):<br />
		print &#8220;&#8221;,<br />
		print &#8221; &#8220;.join([m + ":" + str(di.di(id(eval(m)))) for m in val_name])</p>
<p>if __name__ == &#8216;__main__&#8217;:<br />
	total = 0<br />
	for n in range(10):<br />
		total += n<br />
		Debug.show(&#8220;n&#8221;, &#8220;total&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tiran</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-181095</link>
		<dc:creator>Tiran</dc:creator>
		<pubDate>Wed, 21 Nov 2007 17:18:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-181095</guid>
		<description>Here is just a friendly reminder from me. Python has something like di() already build in:

&gt;&gt;&gt; import _ctypes
&gt;&gt;&gt; _ctypes.PyObj_FromPtr(id(_ctypes))


:)</description>
		<content:encoded><![CDATA[<p>Here is just a friendly reminder from me. Python has something like di() already build in:</p>
<p>&gt;&gt;&gt; import _ctypes<br />
&gt;&gt;&gt; _ctypes.PyObj_FromPtr(id(_ctypes))</p>
<p> <img src='http://www.friday.com/bbum/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bbum&#8217;s weblog-o-mat &#187; Blog Archive &#187; TwistedElephant: A Memory Debugger for Twisted Applications</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-151342</link>
		<dc:creator>bbum&#8217;s weblog-o-mat &#187; Blog Archive &#187; TwistedElephant: A Memory Debugger for Twisted Applications</dc:creator>
		<pubDate>Sat, 15 Sep 2007 17:11:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-151342</guid>
		<description>[...] one-off bits of logging within the target application that used Python&#8217;s GC module and my di() hack such that I could explore the active object graph within the Twisted [...]</description>
		<content:encoded><![CDATA[<p>[...] one-off bits of logging within the target application that used Python&#8217;s GC module and my di() hack such that I could explore the active object graph within the Twisted [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bbum&#8217;s weblog-o-mat &#187; Blog Archive &#187; Python&#8217;s Weakref is weak sauce.</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-150546</link>
		<dc:creator>bbum&#8217;s weblog-o-mat &#187; Blog Archive &#187; Python&#8217;s Weakref is weak sauce.</dc:creator>
		<pubDate>Thu, 13 Sep 2007 05:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-150546</guid>
		<description>[...] little bit ago, I released an itty bitty Python module called di that caused quite the kerfluffle. di is simply the inverse of id; di(id(someObject)) will simply [...]</description>
		<content:encoded><![CDATA[<p>[...] little bit ago, I released an itty bitty Python module called di that caused quite the kerfluffle. di is simply the inverse of id; di(id(someObject)) will simply [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DeanG</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-145712</link>
		<dc:creator>DeanG</dc:creator>
		<pubDate>Sun, 26 Aug 2007 17:18:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-145712</guid>
		<description>Guess we&#039;re not all Consenting Adults here. :-D

A good compromise may be to include it at the same class of feature as Assert: included, but not when run when optimization set at compile time.  Would that be too restrictive for the various debugging environments?</description>
		<content:encoded><![CDATA[<p>Guess we&#8217;re not all Consenting Adults here. <img src='http://www.friday.com/bbum/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<p>A good compromise may be to include it at the same class of feature as Assert: included, but not when run when optimization set at compile time.  Would that be too restrictive for the various debugging environments?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Fein</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-145700</link>
		<dc:creator>Peter Fein</dc:creator>
		<pubDate>Sun, 26 Aug 2007 15:19:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-145700</guid>
		<description>Shalabh: No, my code does not have an id-reuse problem.  id() is called from the __init__.  There&#039;s no way you could end up with two live objects at the same address at the same time.</description>
		<content:encoded><![CDATA[<p>Shalabh: No, my code does not have an id-reuse problem.  id() is called from the __init__.  There&#8217;s no way you could end up with two live objects at the same address at the same time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shalabh</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-145640</link>
		<dc:creator>Shalabh</dc:creator>
		<pubDate>Sun, 26 Aug 2007 06:23:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-145640</guid>
		<description>Ok, I saw the comment about logging an id and finding the object based on the id in the log file, which means the same instance of the interpreter is still running. But you may get a different object back as ids are reused. Peter Fein&#039;s code has the same issue since it uses the id as the key. But it&#039;s a simple enhancement to use (id, count) as they key.</description>
		<content:encoded><![CDATA[<p>Ok, I saw the comment about logging an id and finding the object based on the id in the log file, which means the same instance of the interpreter is still running. But you may get a different object back as ids are reused. Peter Fein&#8217;s code has the same issue since it uses the id as the key. But it&#8217;s a simple enhancement to use (id, count) as they key.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shalabh</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-145639</link>
		<dc:creator>Shalabh</dc:creator>
		<pubDate>Sun, 26 Aug 2007 06:09:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-145639</guid>
		<description>Since ids are reused, how can you be sure the object you got from di is the same one you called id() on? In fact this happens easily on my Mac:
&lt;code&gt;
&gt;&gt;&gt; o = object()
&gt;&gt;&gt; id(o)
5387360
&gt;&gt;&gt; del o
&gt;&gt;&gt; o2 = object()
&gt;&gt;&gt; id(o2)
5387360
&gt;&gt;&gt; 
&lt;/code&gt;

Also, can you tell us why a weakref didn&#039;t work for you? For example, how did you pass the id of the object from the code where the object existed, to the code where the object needed to be &#039;found&#039;?</description>
		<content:encoded><![CDATA[<p>Since ids are reused, how can you be sure the object you got from di is the same one you called id() on? In fact this happens easily on my Mac:<br />
<code><br />
&gt;&gt;&gt; o = object()<br />
&gt;&gt;&gt; id(o)<br />
5387360<br />
&gt;&gt;&gt; del o<br />
&gt;&gt;&gt; o2 = object()<br />
&gt;&gt;&gt; id(o2)<br />
5387360<br />
&gt;&gt;&gt;<br />
</code></p>
<p>Also, can you tell us why a weakref didn&#8217;t work for you? For example, how did you pass the id of the object from the code where the object existed, to the code where the object needed to be &#8216;found&#8217;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hanson</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-145328</link>
		<dc:creator>Chris Hanson</dc:creator>
		<pubDate>Sat, 25 Aug 2007 03:30:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-145328</guid>
		<description>You should get in touch with Guido and see if something like this could be added to Python 3000 core language.  It would be really useful in all sorts of situations!</description>
		<content:encoded><![CDATA[<p>You should get in touch with Guido and see if something like this could be added to Python 3000 core language.  It would be really useful in all sorts of situations!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bbum</title>
		<link>http://www.friday.com/bbum/2007/08/24/python-di/comment-page-1/#comment-145324</link>
		<dc:creator>bbum</dc:creator>
		<pubDate>Sat, 25 Aug 2007 02:46:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.friday.com/bbum/2007/08/24/python-di/#comment-145324</guid>
		<description>Thanks for the code.  While a step in the right direction, there would still be a lot of work left to make it do what I was able to do based upon di().   It is about 9 lines of code longer than what I needed. ;-)

In the end, my particular problem -- stupid huge amounts of memory leaks due to overrooting of objects -- has been solved very very quickly with minimal fuss and full cognizance of the limited applicability of the model.

Sometimes a quick, nasty, intrusive, and fragile hack is &lt;i&gt;exactly&lt;/i&gt; the right answer.</description>
		<content:encoded><![CDATA[<p>Thanks for the code.  While a step in the right direction, there would still be a lot of work left to make it do what I was able to do based upon di().   It is about 9 lines of code longer than what I needed. <img src='http://www.friday.com/bbum/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>In the end, my particular problem &#8212; stupid huge amounts of memory leaks due to overrooting of objects &#8212; has been solved very very quickly with minimal fuss and full cognizance of the limited applicability of the model.</p>
<p>Sometimes a quick, nasty, intrusive, and fragile hack is <i>exactly</i> the right answer.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
