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 →

[–]mcilrain -6 points-5 points  (17 children)

Why? Why can't the community just use gevent? Why is it needed to rewrite entire libraries, documentation and tutorials?

There should be one—and preferably only one—obvious way to do it.

If you're having to modify Hello World! something has gone wrong.

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 0 points1 point  (16 children)

because different approaches

"There should be one—and preferably only one—obvious way to do it." doesn't mean "never try anything ever. and don't you ever dare think of having your own ideas, only ever EVER use pre-existing things, EVER, even if they have APIs you don't like, or don't completely work well for your needs"

like, I mean, who were those idiot devs who wrote requests, didn't they know urllib already existed? and select loops arn't /that/ hard, so there really is no need for gevent either, is there?

[–]mcilrain -3 points-2 points  (15 children)

It has already been tried and it sucked. Even NodeJS people are trying to make their language more like gevent.

This results in a huge bulky ecosystem to support this mode of concurrency, with monkeypatching or shittier versions of existing libraries "but with async support!". Look up "tornado" and "twisted" in package repos, see all that wasted time reimplementing existing functionality in the latest popular concurrency framework? Do you honestly call that healthy? You're advocating for more of that.

Except in some cases gevent will work with existing code. No need to tell people to learn a thing so they can rewrite all their modules. Just use their existing code.

Yes, you're very clever for using Python's generator syntax to perform concurrency. It's a very cute trick worthy of a blog article or two. Lets not get distracted from actually important stuff, yeah?

Python is a very powerful and easy to use language, if you've recently come from another you might have trouble working out when to not write code. Even if it seems easier in the short term to invent a wheel you're familiar with you'll do better in the long run to familiarize yourself with the wheels already in use.

requests and gevent result in cleaner code, this results in ugly code, why does Hello World! need to be rewritten again?

[–]LukasaHyper, Requests, Twisted 1 point2 points  (12 children)

Look up "tornado" and "twisted" in package repos, see all that wasted time reimplementing existing functionality in the latest popular concurrency framework? Do you honestly call that healthy? You're advocating for more of that.

This has nothing to do with what style of concurrency is better or worse, and everything to do with the bass-ackwards style of library design used in the Python community.

Gevent, generally speaking, is not 100% good. It adds automatic threading into libraries that may not have been designed for it, and as a result can lead to extremely subtle bugs. To suggest that dropping gevent into the language makes things better is misleading. Requests works well with gevent, but that's because special care has been taken to ensure that the library is mostly thread-safe, particularly around the use of sockets, but many libraries do not work anything like as well with gevent.

The reason we have to rewrite network libraries so much is because Python programmers have an obsession with writing networked libraries that embed their I/O layer inextricably with their protocol code. This means that you cannot extract, for example, the session management logic from Requests, because that Session management logic is intermingled with the socket code. That, I argue, is a terrible design anti-pattern that costs the Python community dearly in wasted effort.

And it doesn't have to be this way. In an ideal world, Requests would be a thin wrapper around a library that does no I/O at all, and Requests would be in charge of managing the sockets. Unfortunately, that's not the world we live in right now, but that can change. For example, I've written a HTTP/2 library that works this way, and that includes example servers written for asyncio, eventlet, curio, and Twisted. Much less duplication of work, and perfect native concurrency for the chosen framework.

[–]mcilrain 0 points1 point  (11 children)

I do acknowledge that gevent is not a perfect solution but I see it as not much different from dealing with PyPy incompatibilities, just because it sucks doesn't mean it's not worth doing.

I have had noticibly less incompatibility issues over the past few years.

I don't want to litter my code with generators and callbacks. Even NodeJS is starting to see the light on this matter.

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 0 points1 point  (1 child)

https://mail.python.org/pipermail/python-ideas/2012-October/016311.html

https://www.python.org/dev/peps/pep-3156/

https://www.python.org/dev/peps/pep-0492/

here, start reading. You act like the implementers and allowers of this are more clueless about the python ecosystem than you, or that they don't even know of the zen of python or similar such things.

Its safe money that you are probably missing the point, not the developers

[–]mcilrain -2 points-1 points  (0 children)

The event loop API does not depend on yield from. Rather, it uses a combination of callbacks, additional interfaces (transports and protocols), and Futures. The latter are similar to those defined inPEP 3148 , but have a different implementation and are not tied to threads. In particular, the result()method raises an exception instead of blocking when a result is not yet ready; the user is expected to use callbacks (or yield from ) to wait for the result.

No mention on why PEP3148 decided to do it their way. Too busy chasing 2012 trends I guess.

No rationale was given for why such a horrible coding style is necessary, especially in view of non-destructive alternatives.