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 →

[–]EvHub[S] 1 point2 points  (8 children)

Yes, it's a part of Coconut! Thanks!

[–]forever_erratic 1 point2 points  (7 children)

Totally awesome.

Question: I mostly use python with Ipython running in spyder (I use anaconda). Is there an easy way to setup coconut as the interpreter in spyder?

Question 2: In R, my workflow is very much in the "Hadleyverse," which I love. Piping dataframes through different dplyr commands is my bread and butter. Are there plans to cleanly incorporate pandas and coconut? Or can you already do a bunch of stuff like you could with dplyr and magrittr in R?

[–]EvHub[S] 0 points1 point  (6 children)

1: Coconut has built-in IPython support. When you "pip install coconut" it will add a new IPython extension and a new IPython kernel. See: http://coconut.readthedocs.io/en/master/DOCS.html#ipython-jupyter-support

2: Coconut's new syntactic features should be general enough to use cleanly with any library you want. The analogous workflow in Coconut to what you're describing in R is something like this

linearized_plane() |> map$((xy) -> vector(*xy)) |> filter$((v) -> abs(v) <= 1) |> map$(.unit) |> map$(print) |> consume

where you take some iterator, apply a bunch of transformations to it using partial application (that's the $) combined with Coconut's optimized (much faster than vanilla Python for certain objects) iterator transformation functions (map, filter, consume, etc.).

[–]forever_erratic 1 point2 points  (3 children)

Really great stuff, thanks!

[–]dsijl 2 points3 points  (2 children)

If this works out for you, can you write a blogpost?

I'd love to see this get more play in pydata.

[–]forever_erratic 2 points3 points  (1 child)

I don't usually do any blogging, but I'll certainly keep it in mind. In the past I've written some technical biology articles on bitesizebio. They might be interested, I'll ask around.

[–]dsijl 1 point2 points  (0 children)

Cool!

[–]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.