11.11.20 02:46, Skip Montanaro пише:
> I can think of two reasons. One, this kind of comparison will almost never
> appear in production code (maybe in unit tests?). Unlike the C family of
> languages, Python doesn't have a macro processor which would give symbolic
> names to numeric constants or s
>
> On the contrary, comparison remains for runtime:
> >>> dis.dis(compile('1 < 2', filename='', mode='eval',
> >>> optimize=2))
> 1 0 LOAD_CONST 0 (1)
> 2 LOAD_CONST 1 (2)
> 4 COMPARE_OP 0 (<)
> 6 RETUR
On Wed, Nov 11, 2020 at 4:01 AM David Kolovratník wrote:
> On the contrary, comparison remains for runtime:
> >>> dis.dis(compile('1 < 2', filename='', mode='eval',
> >>> optimize=2))
> 1 0 LOAD_CONST 0 (1)
> 2 LOAD_CONST 1 (2)
>
On 11/10/2020 1:03 PM, Barry Scott wrote:
On 10 Nov 2020, at 14:45, David Kolovratník wrote:
Dear all,
I would like to learn about constant folding optimisation in Python. It seems
to be implemented in Python/ast_opt.c. In order to get impression I used
python3 and dis module:
$ python3 -V
> On 10 Nov 2020, at 14:45, David Kolovratník wrote:
>
> Dear all,
>
> I would like to learn about constant folding optimisation in Python. It seems
> to be implemented in Python/ast_opt.c. In order to get impression I used
> python3 and dis module:
>
> $ python3 -V
> Python 3.7.3
I do not h
Dear all,
I would like to learn about constant folding optimisation in Python. It seems
to be implemented in Python/ast_opt.c. In order to get impression I used
python3 and dis module:
$ python3 -V
Python 3.7.3
Arithmetics expression is folded as expected:
>>> dis.dis(compile('1 * 2', filename=