Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.10.X] Turn off debug information in C extension #4863

Closed
wants to merge 1 commit into from

Conversation

bluetech
Copy link

Previously, pydantic used the default Python CFLAGS which include -g (debug level 2). This is good for debugging at the C level, but it significantly increases the size of the C extension shared library, and is probably not needed by the vast majority of pydantic users. Thus, it seems a better tradeoff to turn debug info off.

This can be overridden when building pydantic from source (not from PyPI wheel) by using CFLAGS='-O3 -g'.

This change reduces the pydantic binary on cp310-linux-x86_64 from 31MB (12MB wheel) to 8.9MB (3MB wheel).

Fixes #2276

Previously, pydantic used the default Python CFLAGS which include `-g`
(debug level 2). This is good for debugging at the C level, but it
significantly increases the size of the C extension shared library, and
is probably not needed by the vast majority of pydantic users. Thus, it
seems a better tradeoff to turn debug info off.

This can be overridden when building pydantic from source (not from PyPI
wheel) by using `CFLAGS='-O3 -g'`.

This change reduces the pydantic binary on cp310-linux-x86_64 from 31MB
(12MB wheel) to 8.9MB (3MB wheel).

Fixes pydantic#2276
@bluetech
Copy link
Author

In addition to CI tests, I've tested this by building a wheel after this change, installing it in my project, and verifying that all of my tests pass.

@samuelcolvin
Copy link
Member

I've already created #4862 with some other additions

@samuelcolvin
Copy link
Member

By the way, thanks so much for your recommendation on #2276, I'm a bit embarrassed by how simple the change is once you had done the research to find a solution.

@bluetech
Copy link
Author

Thanks @samuelcolvin, #2276 looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants