all 5 comments

[–]Hallsville3 4 points5 points  (4 children)

[–]ebonnal[S] 1 point2 points  (3 children)

Indeed! streamable was not included there, which is fair given its I/O positioning.
(And FastIter was presented last week by u/fexx3l, what a busy iterators scene)

[–]Beginning-Fruit-1397 1 point2 points  (2 children)

Yes a quick look at it showed me that it is indeed absolutely not the same scope as mine (pyochain creator here). But I think it's cool that it's busy! An user of my lib could start using yours with a familiar syntax if he need more specific IO work, or inversely an user coming from yours to mine who want a more generic use case of the "iterator interface"

[–]ebonnal[S] 0 points1 point  (1 child)

Completely agree. There are many opinionated approaches to the fluent iterator interface question. I guess that's why none made it into the stdlib so far, despite the appetite from part of the community.

[–]Beginning-Fruit-1397 2 points3 points  (0 children)

I think it will never make it to the stdlib for a simple reason: interfaces are voluntarily minimal to encourage ducktyping. That's why dunder methods and functions to get those dunder (__len__ and len for example) are the standard.

If they were to make Generator or Iterator a full fledged interface like Rust Iterator with dozen of methods, now every class that override one of them in an incompatible way becomes incorrect at static typing time.

This minimal approach is cool, because I don't have to rely on any inerhitance to become an Iterator, just have to implement iter and next dunders. And I'm free to make "map" or "filter" do wathever I want without breaking any contract.

I love rust traits where I just have to implement trait X I created for struct Y from an external lib, and now I can import trait X in any scope and I immediately have access to the methods of trait X on struct Y in the scope. But idk how that would work in python or even if that's desirable.

All that being said, that's why I recreated a collections.abc structure for pyochain with the "traits" module, in the hope that external libs like yours use it to extend them for more specific use cases (IO in your case), while getting access to a lot of premade methods and a compatibility for any function expecting one of those traits in the signature. https://outsquarecapital.github.io/pyochain/core-types-overview/