Adding fields to a class via setattr vs. storing a dictionary in Python
<p>I have a class called User:</p>

<pre><code>class User(object):

    def __init__(self, arg1, ..., traits = None):
        self.arg1 = arg1
        ...
        self.traits = traits
</code></pre>

<p>User has a property <code>traits</code> which is a dictionary. It's intended to be a catch-all that I can populate when I need to hold a bit more information about a user other than basic stuff like email address, userID, etc.</p>

<p>Would it be any more or less efficient to create a <code>Traits</code> class, and set the properties in it's <code>__init__</code> with <code>setattr</code>? Would lookups work any better? Is there anything that this machinery would buy me, or is it just more work in the end?</p>
