pyutils / line_profiler

Line-by-line profiling for Python
Other
2.57k stars 118 forks source link

PyPy build error: 'struct PyCodeObject' has no member named 'co_code' #187

Open jakirkham opened 1 year ago

jakirkham commented 1 year ago

Running into an issue building line_profiler on PyPy 3.8. In particular am seeing an error with this line where co_code appears undefined?

https://github.com/pyutils/line_profiler/blob/83e4332c065d8f8b8bc602b99c908955a11aacc2/line_profiler/_line_profiler.pyx#L20

Here's the CI build. Also have attached the log file. This affects PyPy 3.9 as well (CI build and attached log file).

jakirkham commented 1 year ago

cc @mattip (in case you have thoughts on how this could be adapted for PyPy)

Theelx commented 1 year ago

Ah, I didn't think line_profiler was supposed to support PyPy, so I didn't test for it originally. @Erotemic should I put time into making line_profiler 4.x work for PyPy too, or is this a niche use case that doesn't need to be supported?

In my experience, many projects that use C-extensions don't support PyPy because it introduces a bunch of headaches, but I'm willing to try and work on supporting PyPy once my exam season finishes.

Erotemic commented 1 year ago

It would be really nice if we could add PyPy support. I don't think the project ever supported it officially, otherwise we would have CI tests that would have prevented us from merging 4.0. Not sure how conda forge ever had it working in the first place. If you guys have thoughts on how we can update our build to support PyPy, I'd be happy to add it.

mattip commented 1 year ago

I am not sure that supporting PyPy in a line-profiler would be a good use of scarce developer resources. What happens once the JIT kicks in and the code is mutated? In the main use case for PyPy this would happen in the very places profiling is desired, since that is the hot code path. In general, a profiling strategy that requires analyzing frames is going to have a hard time with PyPy.