Just curious:
Is python with vs. without "-O" equivalent today regarding line numbers?
Are SET_LINENO opcodes a plus in some situations or not?
Next, I see quite often several SET_LINENO in a row in the beginning
of code objects due to doc strings, etc. Since I don't think that
folding them into one SET_LINENO would be an optimisation (it would
rather be avoiding the redundancy), is it possible and/or reasonable
to do something in this direction?
A trivial example:
>>> def f():
... "This is a comment about f"
... a = 1
...
>>> import dis
>>> dis.dis(f)
0 SET_LINENO 1
3 SET_LINENO 2
6 SET_LINENO 3
9 LOAD_CONST 1 (1)
12 STORE_FAST 0 (a)
15 LOAD_CONST 2 (None)
18 RETURN_VALUE
>>>
Can the above become something like this instead:
0 SET_LINENO 3
3 LOAD_CONST 1 (1)
6 STORE_FAST 0 (a)
9 LOAD_CONST 2 (None)
12 RETURN_VALUE
--
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252
Is python with vs. without "-O" equivalent today regarding line numbers?
Are SET_LINENO opcodes a plus in some situations or not?
Next, I see quite often several SET_LINENO in a row in the beginning
of code objects due to doc strings, etc. Since I don't think that
folding them into one SET_LINENO would be an optimisation (it would
rather be avoiding the redundancy), is it possible and/or reasonable
to do something in this direction?
A trivial example:
>>> def f():
... "This is a comment about f"
... a = 1
...
>>> import dis
>>> dis.dis(f)
0 SET_LINENO 1
3 SET_LINENO 2
6 SET_LINENO 3
9 LOAD_CONST 1 (1)
12 STORE_FAST 0 (a)
15 LOAD_CONST 2 (None)
18 RETURN_VALUE
>>>
Can the above become something like this instead:
0 SET_LINENO 3
3 LOAD_CONST 1 (1)
6 STORE_FAST 0 (a)
9 LOAD_CONST 2 (None)
12 RETURN_VALUE
--
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252