Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run_multiple_random_inserts():
from pyrsistent import _pvector as _pvector
indices = [2, 405, 56, 5067, 15063, 7045, 19999, 10022, 6000, 4023]
for x in range(4):
indices.extend([i+318 for i in indices])
print("Number of accesses: %s" % len(indices))
print("Number of elements in vector: %s" % max(indices))
original = _pvector(range(max(indices) + 1))
original2 = _pvector(range(max(indices) + 1))
# Using ordinary set
start = time.time()
new = original
for r in range(10000):
for i in indices:
new = new.set(i, 0)
print("Done simple, time=%s s, iterations=%s" % (time.time() - start, 10000 * len(indices)))
assert original == original2
# Using setter view
start = time.time()
evolver = original.evolver()
for r in range(10000):
for i in indices:
def run_multiple_random_inserts():
from pyrsistent import _pvector as _pvector
indices = [2, 405, 56, 5067, 15063, 7045, 19999, 10022, 6000, 4023]
for x in range(4):
indices.extend([i+318 for i in indices])
print("Number of accesses: %s" % len(indices))
print("Number of elements in vector: %s" % max(indices))
original = _pvector(range(max(indices) + 1))
original2 = _pvector(range(max(indices) + 1))
# Using ordinary set
start = time.time()
new = original
for r in range(10000):
for i in indices:
new = new.set(i, 0)
print("Done simple, time=%s s, iterations=%s" % (time.time() - start, 10000 * len(indices)))
assert original == original2
# Using setter view
start = time.time()
evolver = original.evolver()
for r in range(10000):
for i in indices:
evolver[i] = 0
def create_small_native_pvector():
for x in range(100):
_ = _pvector(small_list)
def create_empty_python_pvector():
for x in range(1000):
_ = _pvector()
def _small_python_vector():
small_python_vector = _pvector(range(10))
def append_native_pvector():
v = _pvector()
for x in range(100):
v = v.append(x)
def create_small_python_pvector():
for x in range(100):
_ = _pvector(small_list)
def create_empty_native_pvector():
for x in range(1000):
_ = _pvector()
def _large_native_vector():
large_native_vector = _pvector(range(2000))
def _small_native_vector():
small_native_vector = _pvector(range(10))