New submission from STINNER Victor <vstin...@python.org>:

Measure using this script on the main branch (commit 
108e66b6d23efd0fc2966163ead9434b328c5f17):
---
import _testcapi
def f(): yield _testcapi.stack_pointer()
print(_testcapi.stack_pointer() - next(f()))
---

Stack usage depending on the compiler and compiler optimization level:

* clang -O0: 9,104 bytes
* clang -Og: 736 bytes
* gcc -O0: 6,784 bytes
* gcc -Og: 624 bytes

-O0 allocates around 10x more memory.

Moreover, "./configure --with-pydebug CC=clang" uses -O0 in CFLAGS, because 
"clang --help" output doesn't containt "-Og". I'm working on a configure change 
to use -Og on clang which supports it.

----------
components: Build
messages: 412252
nosy: vstinner
priority: normal
severity: normal
status: open
title: Python built with clang -O0 allocates 10x more stack memory than clang 
-O3 on a Python function call
type: performance
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46600>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to