Multiprocessing Python cannot update list of dict in O(1)

Viewed 52

https://bugs.python.org/issue6766

The bug was found at 2009, but it seems still a bug nowadays.

Anyone could tell me how to update a value in O(1) time?

from multiprocessing import Manager

m = Manager()
d = m.dict()
d[1] = {}
d[1][1] = []

# but:
# 1 not in d[1]

because the value of d[1] is unpicklable

so I have to do like:

d[1] = {}
# if i want to update d[1][1]
d[1] = {1: []} or 
d[1] = {1: [1,2,3,...]}

with the length of list of d[1][1] growing, the cost of time will grown as O(n) which is too slow

Thanks in advance!

0 Answers
Related