Skip to content

random.rand_cid with n > 0 returns duplicates #15

@snarfed

Description

@snarfed

Hi all! Thanks again for building and maintaining dag-cbor.

I noticed just now that when you call rand_cid with n > 0, it pretty much always returns duplicates. Is that intentional? As a user, I was surprised. Any chance you could consider changing that to make it always return n unique CIDs?

>>> from dag_cbor.random import rand_cid
>>> len(set(rand_cid(100)))
93
>>> len(set(rand_cid(100)))
88
>>> len(set(rand_cid(100)))
89
>>> len(set(rand_cid(100)))
85
>>> len(set(rand_cid(100)))
82

This is on dag-cbor 0.3.3, Python 3.12.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions