JulienPalard / Pipe

A Python library to use infix notation in Python
MIT License
1.95k stars 113 forks source link

Drawbacks of using this library #105

Open jmpanfil opened 3 months ago

jmpanfil commented 3 months ago

I love pipes in R, so this is a very enticing option for me. However, what are the main drawbacks of using this library? I imagine:

Great work and thank you!

JulienPalard commented 3 months ago
* It's not "pythonic"

Clearly not Pythonic...

* No type hinting support

For the moment, but it could be typed, maybe, in the future (see https://github.com/JulienPalard/Pipe/issues/76 about this topic).

* Is performance affected?

I'd bet performances are not affected: I'm just using Python generators, the only added cost is one or two function calls per | (not per element traveling the pipe! There's no function calls during the work, only during the setup). (calling a function is not that free in Python). So on very small datasets, on the nanosecond level, you could notice the diff (as long as functions calls are taking a time in the same order of magnitude that the computation being done), but on bigger datasets, you should not (computing things will take orders of magnitude more than calling a few functions).

I have never ran benchmarks on it though and we know that trying to guess performance is a trap :D

You forgot to mention a drawback: exposing operator overloading with different semantics than expected could lead to surprises: imagine the situation where someone wants to use the real bitwise-or operator on the result of a Pipe from my library: it won't work as the overload from my library will be called first. OK the probability that someone wanting this is very very low... but yet I consider it a drawback.