Live data from Hacker News

Show HN: Pip Imports in Deno

github.com

31–40 of 46 posts

Re: Show HN: Pip Imports in Deno

#31
post #27

Earlier quoted context omitted.

why can't you just exec a python shell command to do the same thing? i'm actually slightly puzzled that "FFI" is its own thing when every language has a way to exec shell commands

You can if you are just executing a static python script never changes. But if you want to call some python functions with your TS input then you would need to serialize the TS input, pass it as an arg to the script, there deserialize it and then call the python function with the input. And if you wanted to call multiple python functions then your first arg to the python script would need to be the name of the functi…

right. ok. thats not hard^? like at all? and in fact ive had multiple bugs that ultimately had to do with serialization being quietly abstracted over for me that if i had just handrolled it myself i probably wouldve been consciously aware of my bad choices.

^i know this is probably arrogance out of naivete, just teasing out what exactly i dont know that i dont know about what FFI does.

Re: Show HN: Pip Imports in Deno

#33
post #9

It would be magical if we also got typescript type hints too.

That sounds like a completely different beast of a tool

Not so much you can use inspect [0] to see a whole lot of information. I used this at work to auto generate json scheme of passed functions for openAI function feature [1]

[0] https://docs.python.org/3/library/inspect.html

[1] https://platform.openai.com/docs/guides/gpt/function-calling

Re: Show HN: Pip Imports in Deno

#34
post #29

Is Deno really performing so badly that it has to get PIP'ed? I thought NodeJs would be first...

Not at all but if you have an api in js and you want to do any sort of machine learning, ai, forecasting well all the best tools are in python.

The you have two choices you rewrite your api into python or you call python from your js.

Re: Show HN: Pip Imports in Deno

#36
post #27

Is there an equivalent for Node? I'm glad I haven't needed it since, but I couldn't find anything nearly so seamless when I last looked.

why can't you just exec a python shell command to do the same thing? i'm actually slightly puzzled that "FFI" is its own thing when every language has a way to exec shell commands

deno_python exposes Python modules to JavaScript in a way that makes it possible access the API of any Python module out of the box, as if it were a JS API. Executing a Python shell command is quite different.

Here, FFI is used to interface with the Python Interpreter C API. Argument for FFI against just executing shell commands is performance, efficiency, and that you can make calls from same process instead of spawning a subprocess. When doing [de]serialization over shell interface, a lot of things will be hit and miss. But for deno_python, type conversions are widely supported. You can even pass around objects by reference with zero copy, which would otherwise require copy over a shell interface.

Re: Show HN: Pip Imports in Deno

#37
post #31

Earlier quoted context omitted.

You can if you are just executing a static python script never changes. But if you want to call some python functions with your TS input then you would need to serialize the TS input, pass it as an arg to the script, there deserialize it and then call the python function with the input. And if you wanted to call multiple python functions then your first arg to the python script would need to be the name of the functi…

right. ok. thats not hard^? like at all? and in fact ive had multiple bugs that ultimately had to do with serialization being quietly abstracted over for me that if i had just handrolled it myself i probably wouldve been consciously aware of my bad choices. ^i know this is probably arrogance out of naivete, just teasing out what exactly i dont know that i dont know about what FFI does.

There are limits to what the commandline arguments can take. And even if you fallback to files instead, you still need to serialise a potentially huge amount of data. (Wanna serialise a 1GB tree that is going to get only one lookup in each call to the script?) On top of that, you're missing any chance of in-memory caching, because the script call can't preserve that, while FFI could. Then there are things that are just not possible to serialise like pointers to mapped memory, file descriptors (outside of unix sockets), etc.

Finally even if everything works, a command execution and parsing results is massively slower than a function call. So yeah, there's lots of restrictions on what you can practically do that way.

Re: Show HN: Pip Imports in Deno

#38

The organization name "denosaurs" very roughly works for a combination of deno and python too: snakes fall into the clade of Lepidosaurs. Dinos are Archosaurs. I wonder if there's another programming language featuring a reptile. What's this "Lizard" language Duckduckgo's telling me about?

Cobra

https://en.m.wikipedia.org/wiki/Cobra_(programming_language)

And pushing it a bit as "a language":

Anaconda

Re: Show HN: Pip Imports in Deno

#40
post #28
post #8

So you can now shoot yourself in the foot with both Python and JavaScript package management?

Javascript's package management is so much better than Python's IMO...

Package management, sure. The packages themselves leave a lot to be desired in JS.
Post reply on HN