From 0354bbc5e87ee8f3b378a5fcd15c7ab115932c28 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Wed, 11 Feb 2015 01:20:02 +0500 Subject: [PATCH] some notes about functional libraries --- sep/sep-022.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sep/sep-022.rst b/sep/sep-022.rst index 656d530dd..0b7e1e0f1 100644 --- a/sep/sep-022.rst +++ b/sep/sep-022.rst @@ -93,3 +93,27 @@ Scrapy PRs https://github.com/scrapy/scrapy/pull/1012 https://github.com/scrapy/scrapy/pull/1016 + +Library notes +------------- + +fn.py is nice, but it looks very unusual. + +toolz has a cytoolz counterpart which is implemented in Cython. I was using +cytoolz just to speedup my Python code - with cytoolz code becomes both shorter +and faster. + +[cy]toolz.curried is nice; it allows to write e.g. + +>>> from cytoolz.curried import compose, map, unique +>>> compose(unique, map(unicode.strip)) + +making MapCompose unnecessary - function can be made working on a sequence +by creating a curried map. Specializing map with a result of compose +``map(compose(...))`` is also possible; it becomes the same as Scrapy +MapCompose. + +funcy provides helper functions useful for data extraction; they cover +built-in Join and many of those proposed in +https://github.com/scrapy/scrapy/pull/1012 like regex-based extraction. +See e.g. http://funcy.readthedocs.org/en/stable/strings.html.