You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bytes are immutable in python, which means that repeatedly appending
to them is _quadratic_ in time. That is, we would like and expect
that deleting 10k objects 10 times would take about as long as
deleting 100k, but because we repeatedly concatenate to a bytes object
in the loop, they are not:
timeit.timeit(lambda: server.delete_multi(["foo"]*10000),number=10)
# 0.5087270829999966
timeit.timeit(lambda: server.delete_multi(["foo"]*100000),number=1)
# 10.650619775999985
Switch to using `bytearray` in all palces which handle variable
numbers of bytes. After this change:
timeit.timeit(lambda: server.delete_multi(["foo"]*10000),number=10)
# 0.1197161969999998
timeit.timeit(lambda: server.delete_multi(["foo"]*100000),number=1)
# 0.1269589350000011
0 commit comments