Message261668
| Author |
ztane |
| Recipients |
ztane |
| Date |
2016年03月12日.22:45:45 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1457822745.22.0.972836245522.issue26549@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
When answering a question on StackOverflow, I noticed that a function that only loads a constant tuple to a local variable still has a large `co_stacksize` as if it was built with BUILD_TUPLE.
e.g.
>>> def foo():
... a = (1,2,3,4,5,6,7,8,9,10)
...
>>> foo.__code__.co_stacksize
10
>>> dis.dis(foo)
2 0 LOAD_CONST 11 ((1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
3 STORE_FAST 0 (a)
6 LOAD_CONST 0 (None)
9 RETURN_VALUE
I suspect it is because in the `makecode` the stack usage is calculated from the unoptimized assembler output instead of the actual optimized bytecode. I do not know if there is any optimization that would increase the stack usage, but perhaps it should be calculated from the resulting output. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年03月12日 22:45:45 | ztane | set | recipients:
+ ztane |
| 2016年03月12日 22:45:45 | ztane | set | messageid: <1457822745.22.0.972836245522.issue26549@psf.upfronthosting.co.za> |
| 2016年03月12日 22:45:45 | ztane | link | issue26549 messages |
| 2016年03月12日 22:45:45 | ztane | create |
|