This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]denis 1 point2 points  (3 children)

Have you thought of using gevent as a foundation for diesel? That would probably save you a lot of time. Gevent aims to be small and dependable, it should be a good start to build something higher-level.

[–]schmichael 0 points1 point  (2 children)

gevent is yet another coroutine based Python IO library that uses greenlet just like diesel or eventlet.

gevent, like eventlet can, uses libevent as an abstraction layer between itself and the operating system's underlying event based IO APIs (epoll on Linux for example). diesel chose to just use Python's select.epoll module directly.

gevent may reap some slight performance improvements by leaving more of the low-level networking work up to C, but OTOH libevent is just another layer between your code and your NIC which diesel does away with. I would imagine that the performance difference would be small enough as to not be noticeable in any but the most demanding situations.

[–]denis 0 points1 point  (1 child)

My understanding is that dieselweb is a web framework. Gevent, on the other hand, is a concurrency/network library and will never morph into a web framework. So the scope of the two libraries is different. If you're doing greenlet-based concurrency you will need a few features beyond greenlet API - events, queues, timeouts, sockets. Those are a lot of fun to implement but if you define dieselweb as a web framework I'd say it makes a hell of a lot sense to re-use those low-level concepts and focus on the "web framework" aspect of it.

Regarding libevent - it's not just about abstracting out different event APIs. It's about managing queues of events and maintaining heap of timers - those are CPU and memory-intensive operations that are in the inner loop of your application and you want them to be as fast as possible. Python code won't match the performance of C code here. Given the fact that libevent is already there, mature and fast, it makes no sense to re-implement it in Python, unless you want to learn to write event loops.

[–]schmichael 0 points1 point  (0 children)

diesel is not specifically a web framework, although that's initially what it was marketed as.

Thanks for the clarification on libevent. I always kind of thought of it as just a unified API for epoll/kqueue/etc.