$ pip install --no-deps --user --upgrade coconut pyparsing Collecting coconut Using cached https://files.pythonhosted.org/packages/c9/53/bfbcdcb7c161e2da2ad142a29c79ff0a198062f616596f220c8c2479a764/coconut-1.4.3-py2.py3-none-any.whl Collecting pyparsing Using cached https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl Installing collected packages: coconut, pyparsing Successfully installed coconut-1.4.3 pyparsing-2.4.7 WARNING: You are using pip version 19.2.3, however version 20.1.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. $ coconut Traceback (most recent call last): File "/home/rominf/.local/bin/coconut", line 6, in <module> from coconut.main import main ModuleNotFoundError: No module named 'coconut'
@evhub I'm just discovering https://plydata.readthedocs.io/en/stable/ and https://plotnine.readthedocs.io/en/latest/index.html .... honestly I use coconut pipes for a lot of what I'm seeing here w.r.t. pandas manipulation.
Any thoughts on using plydata to add native dataframe manipulation into coconut? Much like how fmap works on numpy arrays, etc?
__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.