Re:Fastcore: A library that extends Python with new features
by laminatedsmore on Saturday September 05, 2020 @08:17PM
(#24387870)
I think a python implementation of flow is in the toolz library as compose_left. I find myself often using the similar pipe function.
- https://toolz.readthedocs.io/en/latest/api.html#toolz.functo...
- https://toolz.readthedocs.io/en/latest/api.html#toolz.functo...
Re:Fastcore: A library that extends Python with new features
by marmaduke on Saturday September 05, 2020 @04:44PM
(#24386715)
Ok but what’s with the pre post meta init thing? Let’s see a junior run a debugger through that! Dropping one line of code costs several stack frames in your debug session.
Re:Fastcore: A library that extends Python with new features
by jph00 on Saturday September 05, 2020 @05:20PM
(#24386925)
It's a feature from the standard library. However it's only normally available in dataclass. fastcore simply brings the same functionality to other classes too.
Re:Fastcore: A library that extends Python with new features
by dragonwriter on Monday September 07, 2020 @08:12PM
(#24404017)
dataclass has __post_init__ as a mechanism for doing what you'd normally do in __init__ besides what dataclasses do in the generated __init__, because the generated __init__ means you can't do it in __init__, and otherwise you'd have to override (and replicate the function of) the generated __init__.
It is not equivalent to PrePostMetaInit.
Re:Fastcore: A library that extends Python with new features
by dragonwriter on Monday September 07, 2020 @08:06PM
(#24403984)
Theres a lot of good stuff here (@delegates, partialler), sure, but then there's things like the extended Pathlib with pickle functionality; @typedispatch is a nice concept, but the multimethod seems to be more complete implementation of the concept that's been around much longer, so I'm not sure if there is a good case for it that I'm missing or it's just NIH.
Multiple dispatch is also a great thing as well. You don’t realize you need it until you try implementing something unification algorithm.
Compose is nice for reducing the mental overhead of reading nested expressions. However, I do wish they took a line from lodash and implemented flow instead (like compose but reversed so the first argument is invoked first, then the output of that is fed into the second, and so on).
Syntactic sugar is not bad if it increases signal to noise when reading code or if it prevents erroneous usage.