Better HN
topnewbestaskshowjobs
Log inSign up

rob_smallshire

11 karma · joined Nov 20, 2015 (11y ago) · 4 submissions

Submissions

comment 11y ago · link · parent

You could use the python-transducer library <https://github.com/sixty-north/python-transducers> I mentioned in my other comments to do this. It supports using the same transducers with iterables and push-event coroutine generators.

comment 11y ago · link · parent

Yes, although transducers are more general than iterators. Iterators model lazy series from which you must 'pull' elements. Transducers can also be used with elements that are 'pushed', such as events coming from channels, or whatever. Essentially they decouple the transformation from the mechanisms by which input elements arrive and result elements are received, whilst still allowing separate transformations to be composed into more complex composite transformations.

comment 11y ago · link · parent

Note that the first link has been superseded by https://github.com/sixty-north/python-transducers which is also available on PyPI as https://pypi.python.org/pypi/transducer/

comment 11y ago · link · parent

This code by Cognitect is a fairly literal port of Clojure transducers to Python. If you'd like to see a more Pythonic interpretation of transducers, take a look at Sixty-North's alternative https://github.com/sixty-north/python-transducers