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
jiffe has quit [Ping timeout: 248 seconds]
jiffe has joined #pypy
jcea has quit [Ping timeout: 250 seconds]
tos9 has quit [Quit: leaving]
tos9 has joined #pypy
oberstet has quit [Quit: Leaving]
[Arfrever] has quit [Ping timeout: 265 seconds]
[Arfrever] has joined #pypy
dnshane has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
dnshane has joined #pypy
nikolayclfx has joined #pypy
lritter has joined #pypy
oberstet has joined #pypy
vstinner has joined #pypy
<vstinner> hi. i wrote pythoncapi_compat.h: a header file providing new Python C API functions to old Python versions (up to Python 2.7). i just ported it to PyPy 2.7, 3.6 and 3.7, and i have a few questions
<vstinner> in PyPy, the PyThreadState structure only has 'interp' and 'dict' members
<vstinner> so it's not possible to implement PyThreadState_GetFrame() on PyPy, right? the function was added in CPython 3.9, and pythoncapi_compat.h simply implements it by reading tstate->frame on Python 3.8 and older
<vstinner> by the way, CPython 3.7 added an 'id' member to PyThreadState, but PyPy 3.7 doesn't have it. so i simply don't provide PyThreadState_GetID() on PyPy 3.7
<vstinner> in PyPy, PyFrameObject has no 'f_back' member, so I don't provide PyFrame_GetBack() on PyPy
<mattip> https://foss.heptapod.net/pypy/pypy/-/issues/3423 is about lack of tracing fields in PyThreadState
<mattip> that issue could be expanded to all the missing fields
<vstinner> mattip: i don't know if it's an issue. i'm not sure which projects need to iterate on the frame linked list
<vstinner> at least, i can say that pybind11 access PyFrameObject.f_back and PyThreadState.frame
<mattip> pybind11 does not access f_back on PyPy
<mattip> and
<vstinner> mattip: ah right, so it just works on PyPy :)
<vstinner> mattip: include/pybind11/pybind11.h#L2127 nice. running Python code looks like a good solution, no?
<mattip> are you sure you need PyThreadState_GetID() ? Why not use std::thread::id get_id() ?
<mattip> or any of the other ways to get a thread ID from C?
<vstinner> ok, another question: Python 3.1 added gc.is_tracked(), I don't see this function in PyPy 3.6. i know that the PyPy GC is very different. does it have a concept of objects tracked or not by the GC?
<vstinner> mattip: i'm not sure how PyThreadState.id is used (in Python or C extensions). there is also PyThreadState.thread_id. i don't know why the 'id' member was added
<vstinner> i just wanted to make sure that PyPy doesn't have this function
<vstinner> PyThreadState.id was added by the implementation of the PEP 567
<vstinner> it's used by the asyncio module for an internal get_running_loop() function, the ID is used by an internal cache
<mattip> so it is internal, and does not need to be exposed
<vstinner> mattip: hum. the PyThreadState structure is public, PyThreadState.id is public, and I added PyThreadState_GetID() to Python 3.9
<vstinner> mattip: my plan is to make PyThreadState opaque, so we can properly decide what's internal or not. but right now, in CPython, everything is public :-p (which is an issue)
<vstinner> IMO it's was bad idea to make PyThreadState public in the first place :-p
<vstinner> it's too "low-level" to be exposed directly
<mattip> so remove PyThreadState_GetID from python 3.10 before people start using it
<vstinner> mattip: i asked the author of the PyThreadState.id member what he thinks about it :)
<vstinner> "before people start using it" adding a getter or not doesn't change anything, since the structure is public, people can already uses the new member since Python 3.7
<mattip> gc.is_tracked(): I guess we could add a "is_tracked = lambda x: True" to gc
<mattip> :)
<mattip> adding a function is very different from field lookup in C: it communicates that "we thought about this and decided to add a getter function"
<mattip> s/function/macro/static inline function/
<vstinner> "we thought" in PyThreadState_GetID() case, it was only me :-p most people don't care about the API at all :-p
<vstinner> i conducted a study to see which PyThreadState members are used and how: see https://bugs.python.org/issue39947 if you are curious
<vstinner> for example, i didn't know if some members are only read, or if setters would also be needed
<vstinner> so far, i didn't add any setter for PyFrameObject or PyThreadState
<vstinner> for PyFrameObject, there is a whole PEP about setting variables: https://www.python.org/dev/peps/pep-0558/
<vstinner> hum, sorry if i went too far into the details, it now sounds off-topic for #pypy ;-)
<simpson> It's good context. FWIW I appreciate the hard work that you've put into thinking about this, even though I've been less-than-helpful.
<vstinner> simpson: hehe
<vstinner> simpson: FYI all these things are related to my controversial https://www.python.org/dev/peps/pep-0620/ which remains a draft since June 2020 :-p
jcea has joined #pypy
<larstiq> why is pep-0620 controversial?
<pmp-p> probably an aggregate of small many reasons
<nimaje> I hope the idea to hide implemention details isn't controversial there
<vstinner> LarstiQ: it breaks stuff
<vstinner> LarstiQ: i had to revert the Py_TYPE/Py_SIZE change in Python 3.10 for example. see my article: https://vstinner.github.io/c-api-opaque-structures.html
<mattip> nimaje: you cannot really hid anything in C
<mattip> nimaje: the question is what is "sanctioned" by having a function/macro to access it, and why people are using internal implementation details
<mattip> is there a use pattern that can be avoided by providing a different API?
<simpson> There is a pattern for encapsulation in C, pointer to typedef struct, but it's not airtight and so folks will occasionally dig under it. An example in the C stdlib is FILE*.
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-32/builds/6309 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/7589 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-macosx-x86-64/builds/5513 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-win-x86-64/builds/184 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-s390x/builds/1469 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-aarch64/builds/940 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<mattip> people will do what they need to do to solve their problem, usually by looking on stack overflow or other sites to copy-paste
<mattip> and once that code is written, the next time they will not understand how they got there in the first place
<mattip> s/the next time/the next time they need to touch it/
<bbot2> Success: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/7589 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/7590 [mattip: Forced by command line script, release-pypy3.7-v7.x]
<bbot2> Success: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-32/builds/6309 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-32/builds/6310 [mattip: Forced by command line script, release-pypy3.7-v7.x]
oberstet has quit [Remote host closed the connection]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-win-x86-64/builds/184 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-win-x86-64/builds/185 [mattip: Forced by command line script, release-pypy3.7-v7.x]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-macosx-x86-64/builds/5513 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-macosx-x86-64/builds/5514 [mattip: Forced by command line script, release-pypy3.7-v7.x]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-linux-s390x/builds/1469 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-s390x/builds/1470 [mattip: Forced by command line script, release-pypy3.7-v7.x]
Gustavo6046 has quit [Quit: ZNC 1.8.2 - https://znc.in]
Gustavo6046 has joined #pypy
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64/builds/7590 [mattip: Forced by command line script, release-pypy3.7-v7.x]
vstinner has left #pypy [#pypy]
tos9 has quit [Quit: leaving]
tos9 has joined #pypy
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-32/builds/6310 [mattip: Forced by command line script, release-pypy3.7-v7.x]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-linux-aarch64/builds/940 [mattip: Forced by command line script, release-pypy2.7-v7.x]
<bbot2> Started: http://buildbot.pypy.org/builders/pypy-c-jit-linux-aarch64/builds/941 [mattip: Forced by command line script, release-pypy3.7-v7.x]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-linux-s390x/builds/1470 [mattip: Forced by command line script, release-pypy3.7-v7.x]
andi- has quit [Ping timeout: 268 seconds]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-macosx-x86-64/builds/5514 [mattip: Forced by command line script, release-pypy3.7-v7.x]
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-win-x86-64/builds/185 [mattip: Forced by command line script, release-pypy3.7-v7.x]
andi- has joined #pypy
tos9 has quit [Quit: leaving]
tos9 has joined #pypy
Gustavo6046 has quit [Quit: ZNC 1.8.2 - https://znc.in]
Gustavo6046 has joined #pypy
<bbot2> Failure: http://buildbot.pypy.org/builders/pypy-c-jit-linux-aarch64/builds/941 [mattip: Forced by command line script, release-pypy3.7-v7.x]
andi- has quit [Ping timeout: 258 seconds]
andi- has joined #pypy
lritter has quit [Quit: Leaving]