itacart.serialization.tree_blob.count_vertices

itacart.serialization.tree_blob.count_vertices(blob)[source]

Count leaves in a blob without materialising them.

Parameters:

blob (bytes) – The binary blob.

Return type:

int

Returns:

Leaf count.

Raises:

MalformedBlobError – If the blob fails structural validation.

Example

>>> count_vertices(encode_tree("NE(0625/0451(1,2))"))
2