len(object) or hasattr(object, __iter__)?
<p>(The following is python3-related (if that matter).)</p>

<p>This this the code I've written (simplified) :</p>

<blockquote>
<pre><code>class MyClass:

    def __init__(self):
        self.__some_var = []

    @property
    def some_var(self):
        return self.__some__var

    @some_var.setter
    def some_var(self, new_value):
        if hasattr(new_value, '__iter__'):
            self.__some_var = new_value
        else:
            self.__some_var.append(new_value)
</code></pre>
</blockquote>

<p>I want to replace when setting if their is several "values" (i.e if new_value is an iterable of, in my case, non-iterable objects) and appending if their is only one "value".
I'm concerned about the performance of hasattr so I wonder if I shouldn't use this setter instead :</p>

<blockquote>
<pre><code>    @some_var.setter
    def some_var(self, *args):
        if len(args) &gt; 1:
            self.__some_var = args
        else:
            self.__some_var.append(args)
</code></pre>
</blockquote>

<p>Thank for your attention !</p>
