I did mention before in #13 (comment)
and #13 (comment) that utilising pythons generators and the itertools module had some drawbacks with its "pull" design. Essentially when fanning out when using itertools.tee their is now flow control and one stream will get ahead of the other causing itertools.tee to keep the not yielded objects in memory. However if one does not fan out the code comes together rather nicely.
The alternative is using callbacks like the OSMParser does OSMParser.parse(ways_callback=self.ways_callback). Callbacks are more flexible by allowing messages to be passed back as return values which could prove useful. Using callbacks differs from generators since they have a "push" design, you need to setup you full chain before calling parse. It is still possible to express the same chains using a callback approach.
I will experiment constructing a nice callback chain
I did mention before in #13 (comment)
and #13 (comment) that utilising pythons generators and the
itertoolsmodule had some drawbacks with its "pull" design. Essentially when fanning out when usingitertools.teetheir is now flow control and one stream will get ahead of the other causingitertools.teeto keep the not yielded objects in memory. However if one does not fan out the code comes together rather nicely.The alternative is using callbacks like the OSMParser does
OSMParser.parse(ways_callback=self.ways_callback). Callbacks are more flexible by allowing messages to be passed back as return values which could prove useful. Using callbacks differs from generators since they have a "push" design, you need to setup you full chain before calling parse. It is still possible to express the same chains using a callback approach.I will experiment constructing a nice callback chain