Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:52
    timka commented #50
  • 02:08
    evhub closed #559
  • 02:08
    evhub commented #559
  • 02:08
    evhub labeled #559
  • 02:08
    evhub labeled #559
  • 02:08
    evhub milestoned #559
  • 00:34
    bj0 opened #559
  • Oct 27 23:24
    evhub labeled #551
  • Oct 27 23:24
    evhub commented #551
  • Oct 27 23:23
    evhub closed #551
  • Oct 27 23:23
    evhub commented #551
  • Oct 27 22:01
    bj0 commented #551
  • Oct 27 20:01
    evhub commented #551
  • Oct 27 15:23
    bj0 commented #551
  • Oct 27 08:50
    ruivieira commented #551
  • Oct 14 09:37
    xxdavid commented #551
  • Oct 10 23:17
    evhub labeled #558
  • Oct 10 23:17
    evhub opened #558
  • Oct 07 21:14
    regr4 commented #551
  • Oct 07 20:35
    evhub commented #551
dryprogrammer
@dryprogrammer
I logged in to open an issue to see if anyone else had any catastrophic losses with coconut *.coco. don't try it if you haven't git commit!
Fabien Bourgeois
@Yakulu
@dryprogrammer Sanctuary+Fluture is great IMHO. But there is learning curve ;)
Oh ? You should open an issue on github if you have encountered something reproducible
dryprogrammer
@dryprogrammer
Seeing how much time we spend coding and debugging, that learning curve might be worth it. :)
sure i'll add it to github. oh it's not a bug, more like a feature
Roman Inflianskas
@rominf
Ok, I understood, that I can transpile coconut code to Python and ship it without a need for installing coconut.
dryprogrammer
@dryprogrammer
if I have file1.coco and file2.coco in the folder, coconut *.coco will:
Compiling        file1.coco ...
Compiled to    file2.coco .
Fabien Bourgeois
@Yakulu
@rominf Indeed, you don't have to distribute coconut for final package
dryprogrammer
@dryprogrammer

I logged in to open an issue to see if anyone else had any catastrophic losses with coconut *.coco. don't try it if you haven't git commit!

evhub/coconut#541

22 replies
Roman Inflianskas
@rominf
@Yakulu thanks!
Roman Inflianskas
@rominf
I'm implementing gremlin query language for embedded graph database. Are there any examples on term rewriting written in coconut?
Fabien Bourgeois
@Yakulu
Not sure but as coconut is python 3 superpset, you can progressively implement some coconut from your python files
Which embedded graph database ?
Roman Inflianskas
@rominf
I'm using https://gitlab.com/oddjobz/pynndb2 which is based on LMDB (actually, I'm co-author). The graph database library is not ready yet, so it's in a private GitHub repo.
3 replies
Evan Hubinger
@evhub
@rominf Strange that COCONUT_PURE_PYTHON isn't working for you—can you raise an issue for that? As a temporary workaround, however, pip install --no-deps coconut pyparsing should do what you want.
Evan Hubinger
@evhub
You know what, I think I know what the problem is and I'm not sure if it can be fixed—I'll just change the docs to say to do pip install --no-deps --user --upgrade coconut pyparsing instead of trying to mess with COCONUT_PURE_PYTHON.
Thurston Sexton
@tbsexton
@evhub fyi, put in for coconut support on jupytext mwouts/jupytext#532
Evan Hubinger
@evhub
@tbsexton Looks great! The docs should probably mention jupytext support once it goes live. I've never actually used jupytext before, so I'll have to play around with it.
Roman Inflianskas
@rominf
@evhub Thanks for the suggestion, but it looks like it works only after normal unsuccessful installation, because if I enter this command in a new environment, I get an error:
$ 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'
Evan Hubinger
@evhub
@rominf Hmmm... can you raise an issue for that?
Roman Inflianskas
@rominf
@evhub It was my mistake: I'm using pyenv, so I had to skip --user.
Thurston Sexton
@tbsexton

@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?

Thurston Sexton
@tbsexton
obviously I can just add the dependency, I suppose. It just seems like some decent additions to the list of builtins
Evan Hubinger
@evhub
@tbsexton fmap support is pretty simple if there's an equivalent of map or np.vectorize—if you know of how you would do that in either framework definitely raise an issue and include it and it should be pretty straightforward to implement from there.
You can also just add an __fmap__ to the base class.
Elliott Indiran
@eindiran
This is an interesting PEP: https://www.python.org/dev/peps/pep-0622/
Evan Hubinger
@evhub
That's pretty exciting!
hsolatges
@hsolatges
Hi there. Enjoying Coconut magic! Thanks. Still I am wondering: what would be the nicest way (Coconut's way) to insert an element in a List? Given that 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!
Evan Hubinger
@evhub

@hsolatges You could try something like

def insert(iterable, loc, item) = iterable$[:loc] :: (item,) :: iterable$[loc:]

which is nice because it's more functional and works on any iterable.

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.

hsolatges
@hsolatges
@evhub Awesome! Thank you! :)
hsolatges
@hsolatges
It is nice to have that reiterable function
Roman Inflianskas
@rominf

Hi!
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:

lcn.concept.has(language="lt").edge_all(relation="Synonym")

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)?

Evan Hubinger
@evhub
@rominf I'd have to see your pattern-matching code to take a look at where Coconut is compiling to a bunch of repr calls—can you send a link or put it in a gist?
Evan Hubinger
@evhub
@rominf Should be fixed per #548 in coconut-develop now. Just pip install -U coconut-develop>=1.4.3-post_dev34 to get the fix.
Roman Inflianskas
@rominf
@evhub Thank you for a fast fix! Will try it soon.
Roman Inflianskas
@rominf
Yes, it became much faster!
Mason DeMelo
@MasonDeMelo
Hi all!
I'm interested in contributing to coconut and I'm trying to get a development environment set up, but unfortunately I'm running into some trouble with running "make dev". It looks like it's failing when trying to install cPyparsing, is this something that people have run into before?
Evan Hubinger
@evhub
@MasonDeMelo What's the error that you're getting?
Mason DeMelo
@MasonDeMelo
This is the log:
https://pastebin.com/96hVdJDY
I'm trying to install it in a Python 3.8 Virtualenv on Ubuntu 20.04 LTS
Evan Hubinger
@evhub
@MasonDeMelo It looks like your error is being caused by the C compilation failing. This is often caused by a mismatch in the Python version you're running and the Python libraries used by your C compiler by default. Things you can do: try installing outside of a virtualenv, explicitly set your PATH and/or other environment variables (like LIBRARY_PATH) to point to the right version of the Python libraries, or just don't use cPyparsing and use python pyparsing instead—Coconut functions fine with either.
ShalokShalom
@ShalokShalom
Coco can compile to Python 3 code, yes?
Or only to bytecode?
Evan Hubinger
@evhub
@ShalokShalom Coconut always compiles to Python source code not bytecode. By default, Coconut will compile to universal code which will run the same on any Python version. To specifically target Python 3, just pass --target 3.
ShalokShalom
@ShalokShalom
Fine ^^
What is the most readable?
Evan Hubinger
@evhub
You'll probably get the most readable code with --target sys, but compiled Coconut isn't really meant to be readable. You can also try passing --keep-lines to 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.