__fmap__to the base class.
list.insertreturns None. I would like to insert a midle point inbetween two points:
[(0,1),(1,0)] -> [(0,1), (.5,.5),(1,0)]. I achieved it with a temp copy but I wondér if there is a pipe way, or a better way... Thanks!
If you need it to work on iterators rather than just iterables, though, you might want to do
def insert_iterator(iterator, loc, item) = reit$[:loc] :: (item,) :: reit$[loc:] where: reit = reiterable(iterator)
and if you need the result to be a list you can just call
list at the end.
I'm building a high-performance library for ConceptNet access. I'm already close (the performance on queries with a big number of results is up to 2 times faster than in ConceptNet5, which uses PostgreSQL; on queries with small number of results it's slower ~15%). I'm using Coconut for "compiling" queries like this:
into a list of step objects (I use pattern matching using
addpattern). The problem is that for 10K queries like this my program spends 11 s on compiling steps (23% total time). I looked closely and discovered that 6.5 s (13.5%) is spent on
repr function. But I don't use
repr in my code. As I understand, it's used for easier debugging (throwing exceptions). Could I strip these calls to
repr for better performance (using special flag on compiling for example)?
reprcalls—can you send a link or put it in a gist?
pip install -U coconut-develop>=1.4.3-post_dev34to get the fix.
--target sys, but compiled Coconut isn't really meant to be readable. You can also try passing
--keep-linesto put the Coconut source as comments on the compiled Python, which might help readability in terms of helping you understand what Coconut line generated that Python line.
coconut --displayto look at what various different uses of the pipe operator compile to.