Comment 4 for bug 566902

Revision history for this message
Tamás Nepusz (ntamas) wrote :

Yes, these tuples definitely represent edges. When a Graph object is pickled, Python calls the __reduce__ method of the Graph object, which returns the constructor method and the arguments that should be passed to the constructor in order to reproduce the Graph during unpickling. So, during the pickling process, a huge list of tuples are created that represent the edge list. When unpickling, it is the argument list and the name of the Graph constructor that is actually unpickled, and the constructor is then simply called with the appropriate arguments.

One thing I noticed yesterday is that if I explicitly force the Python GC to collect garbage after every unpickling (by calling gc.collect()), the memory usage grows slower for small graphs, but it still grows nevertheless. At the same time, the number of uncollectable objects as returned by gc.collect() stays zero during the whole process.