cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end ) | use cffi for calling C | if a pep adds a mere 25-30 [C-API] functions or so, it's a drop in the ocean (cough) - Armin
<arigato>
9 of these test files are completely skipped
<arigato>
looking at the test_greenlet_*.py, they are skipped because "No module named __pypy__"
<cfbolz>
uh, wat
<arigato>
so... are they just run on top of cpython, testing cpython?
<cfbolz>
seems I am getting lost again
<cfbolz>
right, that's what -A means, doesn't it?
<cfbolz>
:-(
<cfbolz>
not very useful to *just* run them that way
<arigato>
they test specifically that the code we wrote in lib_pypy works, independently on where
<arigato>
I guess?
<cfbolz>
I suppose
<arigato>
that means that test_greenlet_* are pointless in there, because lib_pypy/greenlet imports _continuation
<arigato>
I'll try to move them to extra_tests
gef_ has quit [Ping timeout: 268 seconds]
gef has joined #pypy
<cfbolz>
arigato: I mean, do they pass?
<arigato>
yes
<cfbolz>
phew, good
<arigato>
trying only now to make the first change to greenlet that really belongs to py3.7 and not default
<cfbolz>
arigato: that's the contextvars one?
<arigato>
yes
<cfbolz>
nice
<cfbolz>
let me know how that goes, I think I implemented contextvars
<arigato>
OK
<cfbolz>
(they could be better, they need an implementation of a clojure-style immutable map data structure, which is hidden in CPython despite it being generally cool. in pypy it's just pure python)
<arigato>
let me see if I get this detail correctly: this 900-lines-of-python _immutables_map is here *only* for contextvars, and *only* to guarantee that copy_context() runs in constant time, right?
<cfbolz>
arigato: log time but yes
<cfbolz>
it's a very nice data structure! I would totally understand if they had also put it into collections, but "nobody got around to it" or something
<arigato>
CPython uses the same one?
<arigato>
then "The function has an O(1) complexity" is a lie?
<arigato>
on their docs
<cfbolz>
arigato: yes, cpython has the same one in C, the python implementation is also from them I think
<cfbolz>
re complexity: hm
<cfbolz>
right, copying is probably O(1), lookup is O(log(n))
<arigato>
bah
<arigato>
in a language where dicts are central to everything, you'd think someone might mention that this dict-like lookup is actually slower
<cfbolz>
:-)
<cfbolz>
arigato: but it would be so cool to have it in rpython, and be able to add an @elidable to lookup!!!
<arigato>
of course I find strange behaviours in greenlet's contextvars, which I'm not sure yet to call a bug of greenlet, of cpython, or just me not understanding
<arigato>
can you think of a case where calling "contextvars.copy_context()" on its own, ignoring the return value, can have any effect?
<cfbolz>
arigato: like the CPython implementation? :-(
<cfbolz>
arigato: uh, I would hope it does nothing?
<cfbolz>
ah no, I see. if there isn't already a context it makes one?
<arigato>
yes, and then you shouldn't be able to tell the difference, ideally
<cfbolz>
but you are?
<arigato>
with greenlets, yes
<cfbolz>
:-(
<arigato>
well they give was is essentially a way to __pypy__.get_contextvar_context(), so sometimes you get None and sometimes you get an empty context
<arigato>
s/was/what
<cfbolz>
right
<cfbolz>
so somehow that should do the same thing as copy_context: if there isn't one, set an empty one, so that it's not observable?
<arigato>
yes, but it doesn't do that, so too bad
<arigato>
indeed, the context I get as list(items())==[]
<arigato>
s/as/has
<arigato>
ah I see (maybe)
<arigato>
...no i don't
<cfbolz>
:-)
<arigato>
(the current issue is that there are tests that distinguish between None and an empty Context, and I can't understand the greenlet-on-cpython exact behavior
<cfbolz>
yeah, it's entirely possible that the details around that are different on pypy
<arigato>
OK that's nonsense and I'll give this detail up
<arigato>
if I change the test like this, later some gr_context attribute reads as None or as an empty Context:
<arigato>
of course these two lines are NOT equivalent
<arigato>
copy_context() runs either later in the new greenlet, or right now
<arigato>
if we run copy_context() now, then the new greenlet is created with None as its contextvars_context, and the run() method of the already-existing Context object restores None in CPython