
Goless: Go-like semantics built on top of Stackless Python - im_dario
https://github.com/rgalanakis/goless
======
sarnowski
IIRC stackless python implemented microthreads and channels before go existed
- thats the whole point of stackless python - so whats the benefit here on top
of that?

[http://www.stackless.com/wiki/Tasklets](http://www.stackless.com/wiki/Tasklets)
[http://www.stackless.com/wiki/Channels](http://www.stackless.com/wiki/Channels)

~~~
f2f
"microthreads", channels, and the select statement predate go at least by a
couple of decades in Alef, Plan9's libthread, Limbo, Newsqueak, etc.

~~~
pjmlp
They go back to Occam and Modula-2, among others, way before your list.

~~~
f2f
"at least" is there for a reason.

~~~
pjmlp
Well, given that you only listed projects where Rob Pike worked on, I wasn't
sure what else covered by your "at least".

------
jmoiron
What tulip should have been.

Being a long time gevent user, I found goroutines pretty familiar and even
unspectacular (no pool.map?!). What really converted me to Go was all of the
other ways I found writing Go programs to be more pleasant and less error
prone than Python programs:

* consistent formatting for all code

* superior distribution story

* compiler magnitudes faster and more effective than pylint

* programs run faster and use far less memory

* far simpler semantics make it easy to read

* higher quality standard components (net/http, eg)

What I traded for this was a 10-20% drop in productivity, which I was fine
with. I use Python for all sorts of quick & dirty tasks still, including some
batch processing where there's a big discovery phase, but I write all my
software in Go.

------
ceptorial
The big question is whether this mimics the "non-blocking" behavior of
goroutines - if you block in a goroutine with a select on a channel in Go (or
rather, if you do ANY synchronous operation, including network calls, channel
operations, etc.), Go will automatically context switch off the goroutine and
run another one. But if you have a tasklet that selects on a channel, will
Goless/Stackless automatically run a different tasklet, or will that tasklet
stall a thread (or worse, the GIL)? What if the tasklet is doing a synchronous
HTTP call or waiting on a future to complete?

~~~
rgalanakis
Hi ceptorial, I have toyed around with this a lot. Ultimately goless is just a
wrapper over stackless a gevent, which bother offer monkeypatches for the
stdlib. So if you want this behavior, you can just monkeypatch first, and
everything _should_ work. I decided not to wrap the monkeypatching (for now)
because I did not want to get bugs about how it doesn't work :) However I
should make note of this in the docs. You should make an issue or PR!

------
pritambaral
I'm pleasantly surprised to see pypy beat go by an order of magnitude in the
select_default benchmarks. Could it be a bug, or is it real?

~~~
jerf
Even if it is real, Go is otherwise going to stomp Python performance-wise.

That's not a statement of pride or fanboyism or whatever... it's just the
nature of the two languages.

However, I have recommended and continue to recommend that if A: you are using
Python B: you want something Go-like and C: Python's performance is currently
good enough for you, Stackless/gevent/perhaps this library is a much better
solution than translating tons of code to another language. You can get a lot
of the bang-for-the-buck with this approach without incurring huge rewrite
costs. If you're starting from scratch with Go-like needs, Go is a better
starting place IMHO, but Stackless/gevent is definitely "good enough", no
sarcasm.

It is, IMHO, a very underestimated library in the Python community. And yes, I
know lots of people know it exists... this is a statement of my yet-higher
opinion of it.

------
kristjanvalur
Hi, I didn't realise this was where all the cool kids hang out. Google alerts
4tw

