Package genlayer.py.storage#

Warning

This is an internal module

class genlayer.py.storage.Array[source]#

Constantly sized array that can be persisted on the blockchain

__init__()[source]#

This class can’t be created with Array()

Raises:

TypeError – always

count(value) integer -- return number of occurrences of value#
index(value[, start[, stop]]) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

class genlayer.py.storage.DynArray[source]#

Represents exponentially growing array (list in python terms) that can be persisted on the blockchain

__init__()[source]#

This class can’t be created with DynArray()

Raises:

TypeError – always

__repr__() str[source]#

Return repr(self).

Return type:

str

append(value: T) None[source]#

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S#
count(value) integer -- return number of occurrences of value#
extend(values)#

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value[, start[, stop]]) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(index: int, value: T) None[source]#

S.insert(index, value) – insert value before index

pop([index]) item -- remove and return item at index (default last).[source]#

Raise IndexError if list is empty or index is out of range.

remove(value)#

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()#

S.reverse() – reverse IN PLACE

class genlayer.py.storage.TreeMap[source]#

Represents a mapping from keys to values that can be persisted on the blockchain

K must implement genlayer.py.storage.tree_map.Comparable protocol (“<” and “=” are needed)

__eq__(other)#

Return self==value.

__hash__ = None#
__init__()[source]#

This class can’t be created with TreeMap()

Raises:

TypeError – always

__repr__() str[source]#

Return repr(self).

Return type:

str

clear() None.  Remove all items from D.[source]#
compute_if_absent(k: K, supplier: Callable[[], V]) V[source]#
Returns:

Value associated with k if it is present, otherwise get’s new value from the supplier, stores it at k and returns

Return type:

V

get(k: K, default: G = None) V | G[source]#
Returns:

Value associated with k or default if there is no such value

Return type:

V | G

items() a set-like object providing a view on D's items[source]#
Return type:

ItemsView

keys() a set-like object providing a view on D's keys#
pop(k[, d]) v, remove specified key and return the corresponding value.#

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair#

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D#
update([E, ]**F) None.  Update D from mapping/iterable E and F.#

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values#
class genlayer.py.storage.VecDB[source]#

Data structure that supports storing and querying vector data

There are two entities that can act as a key:

  1. vector (can have duplicates)

  2. id (int alias, can’t have duplicates)

Warning

import numpy before from genlayer import * if you wish to use VecDB!