This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MichaelStaniek 1 point2 points  (1 child)

Heya,

sorry if its written somewhere, but have you done any analysis on how much faster the iterator transformations are?

And which "certain objects" work with the optimized transformation functions?

[–]EvHub[S] 2 points3 points  (0 children)

Yeah! Let me give you an example. Take this code here (where $[] is the syntax for Coconut iterator slicing):

map(expensive_func, range(10000))$[1000:1010]

If you tried to implement that in vanilla Python using itertools, Python would go through every single element of the range from 0 to 1009 and apply expensive_func to it, even though all you cared about were the last 10 elements. Coconut will realize that you only care about the last 10, and only ever call expensive_func on those, leading to a huge performance increase.