News for hackers. Stuff that matters.
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by baldfat on Friday December 14, 2018 @07:41AM (#18680393)
Racket has this for C-based APIs. My mind is kind of wondering how this would ever be stable/maintainable to use for Python, but Lua seems possible but I would rather do my scripting in Racket then Lua and use the C APIs directly.

https://docs.racket-lang.org/foreign/index.html

Looking at Julia (Which has a no "boiler plate" philosophy when using C or Fortan) the function is just called.

Interesting to look at for comparison

Julia ccall- https://docs.julialang.org/en/v0.6.1/manual/calling-c-and-fo...

Racket FFI - https://docs.racket-lang.org/foreign/index.html

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by guenchi on Friday December 14, 2018 @08:39AM (#18680681)
I am researching julia's code.

https://github.com/JuliaPy/PyCall.jl/blob/master/src/PyCall....

I guess it is like this: Importing the pycall library is to turn on the python interpreter thread and not interrupt it. Then you can call any python library you want.

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by blattimwind on Friday December 14, 2018 @11:19AM (#18681912)
The GIL is mostly managed by CPython and the host application doesn't touch it directly. Host extension modules may use PyEval_SaveThread et al. just like regular extension modules to release the GIL during blocking operations when called by CPython. There is a separate API for fondling the GIL when you're in a host-created thread (not created by CPython) and want to call CPython. Those are orthogonal (called by CPython vs. calling CPython).
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by blattimwind on Friday December 14, 2018 @11:13AM (#18681843)
> My mind is kind of wondering how this would ever be stable/maintainable to use for Python

CPython has a stable C API for interacting with the interpreter and Python objects. Presumably FLI goes through this API to interoperate with Python, just like any C/C++ application embedding CPython would.

Edit: Yep, https://github.com/guenchi/FLI/blob/master/pycall.sc

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by guenchi on Friday December 14, 2018 @12:40PM (#18682713)
Yes, it embeds the python interpreter into Scheme via C-api.
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by DarkWiiPlayer on Friday December 14, 2018 @02:59AM (#18679235)
I'm pretty neutral to Scheme and the other Lisps, but at the very least this seems like a cool project.
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by akavel on Friday December 14, 2018 @07:48AM (#18680423)
How does Chez Scheme compare vs. CHICKEN Scheme? For a layman, they both seem to compile to binary; Chicken via C, Chez maybe not? Which one has a bigget community?

Also, do you know of any static typing extension for Chez?

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by guenchi on Friday December 14, 2018 @08:35AM (#18680657)
Chez is compile direct to Native Code

Chicken has much more library and bigger community.

BUT...

Chez is the only commercial compiler (before open source) and very stable and fast...

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by rurban on Friday December 14, 2018 @04:46PM (#18685123)
Chez is by far the fastest of all, similar to LuaJIT. Chicken has more libs.

Static? no, maybe Stalin works on Chez

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by mark_l_watson on Thursday December 13, 2018 @09:17PM (#18677907)
I just looked at the repo, haven't tried this yet. Could be very useful to me if tensorflow, pytorch etc. are callable
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by mark_l_watson on Friday December 14, 2018 @07:37AM (#18680366)
BTW, guenchi thanks for writing this code! Much appreciated.
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by guenchi on Friday December 14, 2018 @08:26AM (#18680613)
I have been working hard to promote the construction of the (Chez)Scheme community for a year. Being useful to you is the best gift for me.

By the way, we have a scheme binding of tensorflow. That calling direct by tensorflow's C API.

FLI is in order to solve the problem of calling Numpy by Scheme which is lack of C - api.

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by __Joker on Friday December 14, 2018 @09:33AM (#18681035)
Can anybody explain how this works ? Is it only works for interpreted languages ?
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by guenchi on Friday December 14, 2018 @12:37PM (#18682683)
Every language with FFI has the same ABI. Because they use C Language's ABI to port another language.

Looking at it from another perspective, any language can call another language through this ABI.

So any language with FFI can call any compiled binary code. For interpreted languages, you must embed the runtime (or interpreter).

Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by fithisux on Friday December 14, 2018 @04:00AM (#18679457)
Could be very useful with Lua code.
Re:FLI: A binary interface to let Scheme use Python, Lua, Ru... by phyrex on Friday December 14, 2018 @07:49AM (#18680430)
If that’s your use case you might want to check out https://fennel-lang.org