Efficient way to use python's lambda, map
lambda, list, map-function, performance, python
Solution
The following works for me:
orig = [start]
for x in diff:
orig.append(orig[-1] + x)
Using `map` will create an new array of the same size, filled with `None`. I also find a simple `for` loop more readable, and in this case as fast as you can get.
Problem
I need to store a big list of integers in Bigtable(db). For efficiency I am storing them as diff between 2 consecutive items. for eg: ``` original_list = [1005, 1004, 1003, 1004, 1006] ``` Storing the above list(which actually contains more than 1000k items) as ``` start = 1005 diff = [-1, -1, 1, 2] ``` The closest I could manage is, ``` ltp = [start] map(lambda x: ltp.append(ltp[-1] + x), tick) ``` I am looking for an efficient way to convert it back into original list.