Is there a way to access the number of elements in a hashmap? I can't find any instructions about this in the documentation and nothing I've tried seems to work.

1 Answer 1


It is not possible to get the number of elements in a hashmap in Vyper since it is an implementation of a hash table.

From the Vyper documentation:

Mappings are hash tables that are virtually initialized such that every possible key exists and is mapped to a value whose byte-representation is all zeros: a type’s default value.

The key data is not stored in a mapping. Instead, its keccak256 hash is used to look up a value. For this reason, mappings do not have a length or a concept of a key or value being “set”.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.