I am making a class in Python that relates a lot of nodes and edges together. I also have other operations that can take two separate objects and merge them into a single object
You could keep a class variable and use it for ordinal ids:
class Node(object): _id = 0 def __init__(self): self._id = Node._id Node._id += 1
It also has the benefit that your class will be able to know how many objects were altogether created.
This is also way cheaper than random ids.