[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] No longer enable Py_TRACE_REFS by default in debug build

On 10Apr2019 1227, Nathaniel Smith wrote:
> On Wed, Apr 10, 2019, 04:04 Victor Stinner <vstinner at redhat.com 
> <mailto:vstinner at redhat.com>> wrote:
>     I don't think that I ever used sys.getobjects(), whereas many projects
>     use gc.get_objects() which is also available in release builds (not
>     only in debug builds).
> Can anyone explain what pydebug builds are... for? Confession: I've 
> never used them myself, and don't know why I would want to.
> (I have to assume that most of Steve's Windows downloads are from folks 
> who thought they were downloading a python debugger.)

They're for debugging :)

In general, debug builds are meant for faster inner-loop development. 
They generally do incremental builds properly and much faster by 
omitting most optimisations, which also enables source mapping to be 
more accurate when debugging. Assertions are typically enabled so that 
you are notified when a precondition is first identified rather than 
when it causes the crash (compiling these out later means you don't pay 
a runtime cost once you've got the inputs correct - generally these are 
used for developer-controlled values, rather than user-provided ones).

So the idea is that you can quickly edit, build, debug, fix your code in 
a debug configuration, and then use a release configuration for the 
actual released build. Full release builds may take 2-3x longer than 
full debug builds, given the extra effort they make at optimisation, and 
very often can't do minimal incremental builds at all (so they may be 
10-100x slower if you only modified one source file). But because the 
builds behave functionally equivalently, you can iterate with the faster 
configuration and get more done.

(Disclaimer: I do most of my work on Windows where this has been 
properly developed. What I hear from non-Windows developers is that 
other tools can't actually handle this kind of workflow properly. Sorry.)

The reason we ship debug Python binaries is because debug builds use a 
different C Runtime, so if you do a debug build of an extension module 
you're working on it won't actually work with a non-debug build of CPython.

While it's possible that people misread "Download debug binaries" (the 
text in the installer) and think that it's an actual debugger, I'd 
suggest that your total lack of context here means you should avoid 
making assumptions about users you know nothing about.