How to use the pyrsistent._pvector function in pyrsistent

To help you get started, we’ve selected a few pyrsistent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tobgu / pyrsistent / tests / performance_run.py View on Github external
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:
github tobgu / pyrsistent / tests / performance_run.py View on Github external
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
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def create_small_native_pvector():
    for x in range(100):
        _ = _pvector(small_list)
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def create_empty_python_pvector():
    for x in range(1000):
        _ = _pvector()
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def _small_python_vector():
    small_python_vector = _pvector(range(10))
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def append_native_pvector():
    v = _pvector()
    for x in range(100):
        v = v.append(x)
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def create_small_python_pvector():
    for x in range(100):
        _ = _pvector(small_list)
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def create_empty_native_pvector():
    for x in range(1000):
        _ = _pvector()
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def _large_native_vector():
    large_native_vector = _pvector(range(2000))
github tobgu / pyrsistent / performance_suites / pvector.py View on Github external
def _small_native_vector():
    small_native_vector = _pvector(range(10))