How to use the preshed.maps.PreshMap function in preshed

To help you get started, we’ve selected a few preshed 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 explosion / preshed / tests / test_hashing.py View on Github external
def test_resize():
    h = PreshMap(4)
    h[4] = 12
    for i in range(10, 100):
        value = int(i * (random.random() + 1))
        h[i] = value
    assert h[4] == 12
github explosion / preshed / tests / test_hashing.py View on Github external
def test_insert():
    h = PreshMap()
    assert h[1] is None
    h[1] = 5
    assert h[1] == 5
    h[2] = 6
    assert h[1] == 5
    assert h[2] == 6
github explosion / preshed / tests / test_hashing.py View on Github external
def test_iter():
    key_sum = 0
    val_sum = 0
    h = PreshMap()
    for i in range(56, 24, -3):
        h[i] = i * 2
        key_sum += i
        val_sum += i * 2
    for key, value in h.items():
        key_sum -= key
        val_sum -= value
    assert key_sum == 0
    assert val_sum == 0
github explosion / preshed / tests / test_hashing.py View on Github external
def test_zero_key():
    h = PreshMap()
    h[0] = 6
    h[5] = 12
    assert h[0] == 6
    assert h[5] == 12

    for i in range(500, 1000):
        h[i] = i * random.random()
    assert h[0] == 6
    assert h[5] == 12

preshed

Cython hash table that trusts the keys are pre-hashed

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Similar packages