<?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: What the Hell is a Slot?</title>
	<atom:link href="http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/</link>
	<description>Done, and gets things smart.</description>
	<lastBuildDate>Wed, 17 Mar 2010 19:34:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: LE</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-556</link>
		<dc:creator>LE</dc:creator>
		<pubDate>Wed, 29 Jul 2009 14:54:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-556</guid>
		<description>@Manual management guy above:

No, you can implement the slots in pure Python if you&#039;d like. You&#039;ll be wasting a perfectly good dictionary on each object, but that&#039;s still less processing overhead.

What slots do is they essentially create descriptors for each attribute named. For example: http://pb.lericson.se/p/SkRPZb/

Descriptors are used for implementing static methods, class methods, unbound/bound methods, and properties. They&#039;re very essential to Python&#039;s OOP. Nothing weird.</description>
		<content:encoded><![CDATA[<p>@Manual management guy above:</p>
<p>No, you can implement the slots in pure Python if you&#8217;d like. You&#8217;ll be wasting a perfectly good dictionary on each object, but that&#8217;s still less processing overhead.</p>
<p>What slots do is they essentially create descriptors for each attribute named. For example: <a href="http://pb.lericson.se/p/SkRPZb/" rel="nofollow">http://pb.lericson.se/p/SkRPZb/</a></p>
<p>Descriptors are used for implementing static methods, class methods, unbound/bound methods, and properties. They&#8217;re very essential to Python&#8217;s OOP. Nothing weird.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Basu</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-340</link>
		<dc:creator>Basu</dc:creator>
		<pubDate>Tue, 07 Jul 2009 18:39:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-340</guid>
		<description>One of the philosophical (and somewht practical) dilemmas that i find myself thinking about as a programming languages buff is how much work should the language do and how much should the programmer do. I personally try to stay away from manual management of any sort, but sometimes performance requires it. It&#039;s unfortunate, but soemthing that needs to be done sometimes. I think language features like slots are a good way to bypass the languages dynamic, automated features but should be used only in the final optimization stage of a program&#039;s development cycle.</description>
		<content:encoded><![CDATA[<p>One of the philosophical (and somewht practical) dilemmas that i find myself thinking about as a programming languages buff is how much work should the language do and how much should the programmer do. I personally try to stay away from manual management of any sort, but sometimes performance requires it. It&#8217;s unfortunate, but soemthing that needs to be done sometimes. I think language features like slots are a good way to bypass the languages dynamic, automated features but should be used only in the final optimization stage of a program&#8217;s development cycle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StCredZero</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-339</link>
		<dc:creator>StCredZero</dc:creator>
		<pubDate>Tue, 07 Jul 2009 15:03:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-339</guid>
		<description>Smalltalk just has the slots.  Slots are easier to optimize and make fast with a JIT VM.  If you need a class to have the functionality of a Hashtable, you just put a Dictionary into an instance variable.  (Then you have to write some plumbing code, which is not so convenient.)  

This ability to add slots allows one to put in optimizations if needed, but keeps the default case simple and flexible.  I like that.</description>
		<content:encoded><![CDATA[<p>Smalltalk just has the slots.  Slots are easier to optimize and make fast with a JIT VM.  If you need a class to have the functionality of a Hashtable, you just put a Dictionary into an instance variable.  (Then you have to write some plumbing code, which is not so convenient.)  </p>
<p>This ability to add slots allows one to put in optimizations if needed, but keeps the default case simple and flexible.  I like that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chewie</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-336</link>
		<dc:creator>Chewie</dc:creator>
		<pubDate>Tue, 07 Jul 2009 11:07:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-336</guid>
		<description>Warning: unless you&#039;re using Python 3000, you must use new-style classes for __slots__ to work, i.e., you should write class Foo(object):.</description>
		<content:encoded><![CDATA[<p>Warning: unless you&#8217;re using Python 3000, you must use new-style classes for __slots__ to work, i.e., you should write class Foo(object):.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-335</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Tue, 07 Jul 2009 09:31:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-335</guid>
		<description>This only works on new style classes. Your example should be updated to read:

class Foo(object):
    __slots__ = [&#039;x&#039;]
    def __init__(self, n):
        self.x = n

y = Foo(1)
print y.x  # prints &quot;1&quot;
y.x = 2
print y.x  # prints &quot;2&quot;
y.z = 4    # Throws exception.
print y.z

Cheers though! Very helpful!</description>
		<content:encoded><![CDATA[<p>This only works on new style classes. Your example should be updated to read:</p>
<p>class Foo(object):<br />
    __slots__ = ['x']<br />
    def __init__(self, n):<br />
        self.x = n</p>
<p>y = Foo(1)<br />
print y.x  # prints &#8220;1&#8243;<br />
y.x = 2<br />
print y.x  # prints &#8220;2&#8243;<br />
y.z = 4    # Throws exception.<br />
print y.z</p>
<p>Cheers though! Very helpful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David W</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-327</link>
		<dc:creator>David W</dc:creator>
		<pubDate>Mon, 06 Jul 2009 22:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-327</guid>
		<description>It&#039;s worth note that there are various gotchas regarding slots, particularly since they&#039;re implemented as descriptors. One of my preferred tricks, defining a class variable to act as a default for an instance variable, cannot work, since the slot&#039;s descriptor needs to be in the class dictionary.

It&#039;s also worth note that slots layer up - a little confusingly at first, but quite understandably. You can define a class X(slots=a) and subclass Y(slots=b) and things will work as expected. I have no idea how memory is allocated for that underneath. Perhaps Python&#039;s type object is smart enough to merge them into a single object.

The other last thing worth note is that slots can have a very positive impact on performance, not just on memory usage.

Great post,


David (dwdwdw@Reddit!)</description>
		<content:encoded><![CDATA[<p>It&#8217;s worth note that there are various gotchas regarding slots, particularly since they&#8217;re implemented as descriptors. One of my preferred tricks, defining a class variable to act as a default for an instance variable, cannot work, since the slot&#8217;s descriptor needs to be in the class dictionary.</p>
<p>It&#8217;s also worth note that slots layer up &#8211; a little confusingly at first, but quite understandably. You can define a class X(slots=a) and subclass Y(slots=b) and things will work as expected. I have no idea how memory is allocated for that underneath. Perhaps Python&#8217;s type object is smart enough to merge them into a single object.</p>
<p>The other last thing worth note is that slots can have a very positive impact on performance, not just on memory usage.</p>
<p>Great post,</p>
<p>David (dwdwdw@Reddit!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bram</title>
		<link>http://www.elfsternberg.com/2009/07/06/python-what-the-hell-is-a-slot/comment-page-1/#comment-326</link>
		<dc:creator>Bram</dc:creator>
		<pubDate>Mon, 06 Jul 2009 22:22:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=297#comment-326</guid>
		<description>FYI, you were posted on reddit: http://www.reddit.com/r/Python/comments/8yqj4/python_what_the_hell_is_a_slot/</description>
		<content:encoded><![CDATA[<p>FYI, you were posted on reddit: <a href="http://www.reddit.com/r/Python/comments/8yqj4/python_what_the_hell_is_a_slot/" rel="nofollow">http://www.reddit.com/r/Python/comments/8yqj4/python_what_the_hell_is_a_slot/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
