3 ms·
>gevent is difficult to use when interoperating with code outside its runtime (e.g. if you have a callback that gets called from a C library) True, but is this
by meowface 6y ago
>gevent is difficult to use when interoperating with code outside its runtime (e.g. if you have a callback that gets called from a C library)
True, but is this not also the case when using Python's native async/await functionality?
The difference is that async/await doesn't even work with previous pure-Python code which performs any I/O, either. There are thousands of ordinary third-party libraries which basically have to be tossed out the window and rewritten from scratch, despite none of them using any C extensions.
gevent works well with almost all of those old libraries.
- lmm 6y ago> True, but is this not also the case when using Python's native async/await functionality? Yes indeed. > The difference is that async/await doesn't even work with previous pure-Python code which performs any I/O, either. There are thousands of ordinary third-party libraries which basically have to be tossed out the window and rewritten from scratch, despite none of them using any C extensions. Hmm, yeah. I sometimes wonder about a language style where functions are monadic by default, and I guess being able to monkeypatch the internals is a way to achieve the same thing - rather than introducing a syntax for a "programmable semicolon", we can just monkeypatch the actual semicolon. Introducing effectfulness into code that wasn't written to accommodate it worries me, but I guess gevent usually works in practice. I guess a language like Frank is a more principled way of doing that kind of thing.
- meowface 6y agoYeah, monkey-patching is pretty much what it sounds like: a monkey ripping stuff out of and bolting stuff onto everything with a wrench. But despite how incredibly ugly and complex it sounds and how much any decent programmer shudders at the thought of it, in practice it seems most people never really run into issues with it if they're using pure-Python non-asyncio libraries. And the external API they provide is really clean; you generally don't have to think about any of the internals. You just use everything exactly like you already would and pepper in straightforward abstractions like gevent.Pool and gevent.spawn. Internally, it might be the antithesis of Pythonic, but the external interface and developer experience is very Pythonic.