cfbolz changed the topic of #pypy to: #pypy PyPy, the flexible snake https://pypy.org | IRC logs: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end and https://libera.irclog.whitequark.org/pypy | the pypy angle is to shrug and copy the implementation of CPython as closely as possible, and staying out of design decisions
epony has quit [Quit: QUIT]
jinsun__ has joined #pypy
jinsun__ is now known as jinsun
jinsun has quit [Killed (iridium.libera.chat (Nickname regained by services))]
epony has joined #pypy
lesshaste has joined #pypy
<lesshaste> I have a performance question. I have some python code that I need to make as fast as possible (it takes 2 weeks to run currently using pypy). Does it make sense to implement the functions that I can using cffi or is the overhead likely to make that irrelevant. There is one function in particular that is run 10^10 times
<cfbolz> lesshaste: can you share the code? what does that function do?
<lesshaste> cfbolz, it performs stick breaking on a list. That is chooses a random number between 0 and the length of the list, breaks that much off and then repeats
<cfbolz> how big are the lists?
<lesshaste> cfbolz, less than 1000
<lesshaste> I just need to do it billions of times
<cfbolz> ok. code? or is that private?
<lesshaste> it is private sorry
<lesshaste> but it's simple to reimplement :)
<cfbolz> if you reimplement it and give me some sample data I can take a look
<lesshaste> cfbolz, I am really asking a general question. If I have to call a function 10^10 times, is it work writing it in C using cffi or will that cause an overhead that would make it too costly
<cfbolz> that general question has no answer
<lesshaste> is it worth
<lesshaste> cfbolz, how come?
<lesshaste> what does it depend on?
<cfbolz> the function
<cfbolz> the input and output data
<cfbolz> in your case you would have to copy the list from a python list to a C array, right? that sounds expensive
<lesshaste> yes that does sound bad
<lesshaste> even if I can make the array in C I would have to at least copy it back into python
<lesshaste> which I am guessing is expensive
<lesshaste> so am I right that in general, if the C function needs very little passed to it and returned then the overhead would be minimal?
<lesshaste> thanks for your help as well
<cfbolz> or it needs to run for very long
mattip has quit [Read error: Connection reset by peer]
mattip has joined #pypy
<lesshaste> cfbolz, got you
<lesshaste> how expensive is copying an array from C to python?
<lesshaste> hi mattip
<mattip> lesshaste: hi
<lesshaste> mattip, I didn't submit a bug report about matplotlib, sorry. But has there been any progress since we last spoke/chatted?
<mattip> sorry, I forgot. What was the issue?
<lesshaste> you can't use matplotlib with pypy :)
<lesshaste> at least a non-expert can't
<lesshaste> I will redownload https://downloads.python.org/pypy/pypy3.9-v7.3.11-linux64.tar.bz2 and take it step by step now
<lesshaste> installing matplotlib
<mattip> My answer these days is "use conda, they provide pre-built binary packages"
<lesshaste> mattip, sadly that isn't possible from my work
<lesshaste> I can't be alone
<lesshaste> (it is building the numpy wheel....)
<mattip> ok, then if this is for work,
<mattip> ......
<mattip> .
<lesshaste> it's for me at work :)
<lesshaste> my work doesn't care
<lesshaste> mattip, ok this is the problem https://bpa.st/GQATG
<lesshaste> there are a lot of happy pypy users. It would be awesome of matplotlib worked if installed via pip
<cfbolz> fwiw, I also have seem this tcl error message on my laptop once before
<mattip> weird. That would indicate the tarball does not properly package tkinter
<cfbolz> mattip: it seems to work with 7.3.11 now though
<mattip> lesshaste: does "ls /home/user/Downloads/mypypy3.9/lib/tcl8.5/init.tcl" work?
<lesshaste> No such file or directory
<cfbolz> ah, no, I'm on 7.3.10
<cfbolz> but indeed, looking at strace the init.tcl it loads is from the the expanded download
Dejan_ has joined #pypy
Dejan_ is now known as Dejan
<lesshaste> if I should submit a bug report please let me know
<mattip> yes, please be sure to include all the steps and what OS you are using
<mattip> I could not reproduce on latest py3.9 HEAD, which should be equivalent to the release.
<mattip> and in the release tarball I see
<mattip> pypy3.9-v7.3.11-linux64/lib/tcl8.5/init.tcl
<mattip> are you using a virtualenv or some other redirection?
<lesshaste> mattip, yes I did pypy3.9-v7.3.11-linux64/bin/pypy3.9 -m venv mypypy3.9
<mattip> ok, so maybe the bug is that tkinter does not work inside a venv
<mattip> if you use the base environment, does everything work?
<lesshaste> mattip, bug reported
<lesshaste> mattip, how would I install matplotlib safely outside the virtual env?
<cfbolz> mattip: yes, can confirm that tk breaks in a venv
<lesshaste> cfbolz, thanks for reproducing it!
<cfbolz> lesshaste: as for "outside a virtual env": every if you unpack a downloaded pypy tarball, every one of the unpacked directories is its own world. so you can safely unpack again and directly install matplotlib in there
<lesshaste> cfbolz, ok thanks!
<lesshaste> cfbolz, I can't even find pip in the unpacked tar ball
<cfbolz> lesshaste: pypy -m ensurepip
<lesshaste> cfbolz, I did a different bug :)
<cfbolz> yes?
<lesshaste> this is when I am not in a virtualenv
<cfbolz> lesshaste: can you try to run matplotlib from a script, not in ipython?
dmalcolm_ has joined #pypy
dmalcolm has quit [Ping timeout: 252 seconds]
<lesshaste> cfbolz, that works perfectly
<cfbolz> that's cool!
<lesshaste> maybe I should report another bug/issue
<lesshaste> it is cool :)
<lesshaste> I guess if my reported bug gets fixed it will most likely fix this bug
<lesshaste> what I don't understand is why none of the other thousands of users have reported it
<mattip> wierd. TkApp.dooneevent seems to be an established interface, and the IPython tk backend has been using it for years too
<lesshaste> I am using ipython 8.8.0 if it makes any difference
<mattip> now how do I create a TkApp to test that the attributes in cpython and pypy are equivalent
<mattip> duhh, it is _tkinter.TkApp
<mattip> on cpython it is different: there is a _tkinter.TkappType
<mattip> CPython has these that are missing in PyPy
<mattip> {'__sizeof__', 'adderrorinfo', 'createfilehandler', 'createtimerhandler', 'deletefilehandler', 'dooneevent', 'record', 'willdispatch'}
<mattip> PyPy has these that are not in CPython
<mattip> {'__del__', '__dict__', '__weakref__', '_busywaitinterval', '_callResult', '_check_tcl_appartment', '_createbytearray', '_getvar', '_merge', '_setvar', '_split', '_splitObj', '_tcl_lock_released', '_unsetvar', '_var_invoke', 'merge', 'raiseTclError'}
<lesshaste> hmm
<mattip> what a mess
<lesshaste> is that expected?
<lesshaste> I am guessing not
dmalcolm__ has joined #pypy
dmalcolm_ has quit [Ping timeout: 260 seconds]
jinsun__ has joined #pypy
jinsun__ is now known as jinsun
lesshaste has quit [Ping timeout: 272 seconds]
dmalcolm_ has joined #pypy
dmalcolm__ has quit [Ping timeout: 272 seconds]
dmalcolm_ has quit [Ping timeout: 265 seconds]
dmalcolm has joined #pypy
dmalcolm_ has joined #pypy
dmalcolm has quit [Ping timeout: 246 seconds]
dmalcolm_ has quit [Remote host closed the connection]
dmalcolm has joined #pypy
dmalcolm_ has joined #pypy
dmalcolm has quit [Ping timeout: 260 seconds]
<cfbolz> yaaaaaay, cpy segfault
lesshaste has joined #pypy
epony has quit [Quit: QUIT]
<nimaje> ok, and is there a reason to write such strange code? (yes it shouldn't segfault)
<cfbolz> no
<cfbolz> hence the last sentence
epony has joined #pypy
jcea has joined #pypy
<LarstiQ> lesshaste: all our matplotlib usages specificially pick non tk backends
<lesshaste> LarstiQ, interesting. I don't even know how to do that
<lesshaste> LarstiQ, how could I plot a graph from within ipython without using tk?
dmalcolm__ has joined #pypy
Julian has quit [Quit: leaving]
dmalcolm_ has quit [Ping timeout: 248 seconds]
lesshaste has quit [Read error: No route to host]
lesshaste has joined #pypy
<LarstiQ> we usually pick "agg"
<LarstiQ> it does claim to automatically pick a suitable backend but that doesn't seem to work now?
<lesshaste> LarstiQ, %matplotlib qt
<lesshaste> that failed
jcea has quit [Ping timeout: 252 seconds]
epony has quit [Remote host closed the connection]
epony has joined #pypy
epony has quit [Remote host closed the connection]
epony has joined #pypy
Dejan has quit [Quit: Leaving]
Atque has quit [Quit: ...]