otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #pypy
otisolsen70 has quit [Remote host closed the connection]
jacob22_ has joined #pypy
jacob22_ has quit [Client Quit]
rindolf has quit [Quit: Shlomi Fish ("Rindolf") has left the server. βChuck Norris was challenged to fight the world, and accepted. He bet on himself, won, and collected the bet money.β]
<ctismer>
cfbolz: Yes, in 1999 I decided to decouple the Python stack from the C stack. If Python had followed this idea earlier, we would have saved all the mess with generators and yield from that they use for async. Very messy.
<fijal>
oh god
<fijal>
ok, so tempfile depends on hashlib which depends on tempfile
<fijal>
not sure how to deal with that
<fijal>
how did it ever work is a good question, I guess, but I suppose I changed some files?
<fijal>
ronan: I think the semantics would not change if ffi.new (used in a context manager) would not have a __del__
<fijal>
I'm not sure how to communicate "used in a context manager" though
<ronan>
yes, but you can do anything inside the with, so x.__enter__ should return something that's exactly like x, except for __del__
<ronan>
"used in a context manager" is the return value of __enter__()
<fijal>
yes, but we already have that inside cffi
<fijal>
like W_CDataNewNonStd returns object with _finalize_ and not __del__, for example
<fijal>
which I don't know what it does
<ronan>
fijal: in all cases, the object still has an applevel __del__
<fijal>
why?
<fijal>
I don't see the applevel del?
Julian has quit [Quit: leaving]
<ronan>
fijal: sorry, you're right, there isn't one
<fijal>
so i think we could return the non-standard one?
<arigato>
fijal: I *think* you can try that:
<arigato>
declare "malloc" and "free" inside cdef()
<arigato>
alloc = ffi.new_allocator(lib.malloc)
<arigato>
...no, sorry doesn't work
greedom has joined #pypy
<arigato>
it seems that the standard cdata objects that you can use in "with" constructions also have at least a lightweight finalizer
<arigato>
you can probably write a general helper, to use in "with TempBuf(size) as p: ...p is a cdata object here..."
<arigato>
and get the top speed that way on pypy
<arigato>
if you try and it works we can think about adding that to cffi itself
<arigato>
write the helper as regular python code I mean
the_drow has quit [Read error: Connection reset by peer]
ambv has quit [Read error: Connection reset by peer]
graingert[m] has quit [Write error: Connection reset by peer]
daubers has quit [Remote host closed the connection]
jryans has quit [Write error: Connection reset by peer]
jryans has joined #pypy
<arigato>
alternatively, we could think harder about the problem and come up with a way to have real stack allocations in the JIT
daubers has joined #pypy
the_drow has joined #pypy
graingert[m] has joined #pypy
ambv has joined #pypy
greedom has quit [Remote host closed the connection]
<arigato>
thinking about a pair of rpython functions that do malloc and free, but which the JIT knows about and if both appear in a trace (and the size is small enough) it gets turned into a stack allocation; the real problem is what to do if an intermediate guard leaves the trace
<arigato>
we'd need to insert a "copy_outside_the_stack" operation; and if we then compile the bridge, then we optimize again "copy_outside_the_stack" followed by "free"
<arigato>
that would only work if the rpython code is super careful
<arigato>
or maybe the jit optimizer needs to check all usages of the variable returned by "alloc", and check that they are all OK
greedom has joined #pypy
<arigato>
...well, maybe the first step would be to teach the JIT about lightweight finalizers. I don't think we do so far
<arigato>
too many possible directions to go, none looks easy
<fijal>
heh
<fijal>
I think I would start with a pure-python wrapper
<arigato>
sounds sane
<fijal>
and see if using it in pypy cffi modules helps, then we can think
<fijal>
stack allocation in the jit sounds nice, but I think those functions might not even be jitted or something
<fijal>
they probably are I guess
<fijal>
but seems a bit fishy, maybe a pure python wrapper that has an optimization on top would be ok though
<arigato>
yet another simplified hack for the JIT: add a function in rgc to say "well now I don't really care any more about my lightweight finalizer", and if we see pairs malloc/call-to-that in a trace, then we ignore the lightweight finalizer and optimize like usual
<arigato>
yes, I see the point
greedom has quit [Remote host closed the connection]
greedom has joined #pypy
greedom has quit [Remote host closed the connection]
jacob22 has joined #pypy
mattip_ has joined #pypy
<mattip_>
ronan: is hpy-0.0.3 ready for merging to py3.7 ?