Vectorized functions are way faster than doing it on your own, e.g.
np.exp(a) is faster than
[math.exp(i) for i in a].
I'm creating my own class with several attributes. At some point I want to be able to delete/add new attributes to the several objects. can this be done in a (fast) vectorized way? i.e.
class ClassName: def __init__(self) self.a = 1 self.b = 2
After having initialized some instances of this class and saved them in a list, i.e.
instances = [ClassName() for i in range(100)].
I now want the code
for instance in instances: del instance.a
in the following form:
del instances.a. I know how I could do this by creating a meta class instances which has this attribute/this method. But this would just mask the for loop. Is there a way in which it is actually done in a vetorized, fast way?
In general, how can I tell my classes to have instances, that allow vectorized functions?