Why do python functions have a __dict__?
<p>In Python, functions created using <code>def</code> and <code>lambda</code> have a <code>__dict__</code> attribute so you can dynamically add attributes to them.  Having a <code>__dict__</code> for every function has a memory cost.  An empty <code>dict</code> uses 140 bytes in CPython 2.6.</p>

<p>Adding attributes to a function isn't a particularly common thing to do, and you can use a custom object with a <code>__call__</code> method for the cases where you do need a function with non-standard attributes.</p>

<p>Since adding custom attributes to a function isn't a common use case and having a <code>__dict__</code> has a memory cost why do Python functions have a <code>__dict__</code>?</p>
