Mikhail Korobov, 09.07.2012 01:36:
Yes, these things are rather tricky. Basically, the C code uses a visitor
pattern ("push") and you want to map it to iteration ("pull").
There are ways to do that, but I'd go two steps back and ask some questions
first. Is there really no C interface to the data structure that resembles
iteration more closely? Do you really need to expose it as iterator, or
would a visitor pattern work in Python space as well?
However, in this case, I agree that the visitor pattern looks like a rather
clumsy choice (even in C, which lacks closures after all).
Stefan