python - Fast array/list type for holding numpy ndarrays -
i have lot of list of numpy ndarrays, of different sizes, in code. (i have lists of lists of numpy ndarrays, less issue lists small (<5 elements).)
i have learn ndarrays of ndarrays of different dimention, doesn't workout..
operations tend on it:
- accessing/writing in reverse. (currently writing done reversing list twice)
- appending it
- applying functions on contained ndarrays, eg summing 2 lists of ndarrrays elementwise, multipliplying -1 etc.
i manipulating them following functions (as more direct operations)
def uniop_nested(func,o_list): def inner(i_list): ¦ if isinstance(i_list[0],np.ndarray): ¦ ¦ ¦return map(func, i_list) ¦ else: ¦ ¦ ¦return map(inner, i_list) return inner(o_list) def binop_nested(func, o1, o2): if not isinstance(o1,np.ndarray): ¦ return [binop_nested(func, i1, i2) (i1,i2) in zip(o1,o2)] else: ¦ return func(o1,o2) def add_nested(s1,s2): return binop_nested(np.add,s1,s2)
i'm finding profiling, these lists issue.
Comments
Post a Comment