[issue39823] Disassembly - improve documentation for bytecode instruction class and set source line no. attribute for every instruction

2020-03-02 Thread S Murthy
S Murthy added the comment: Docstring for `Instruction` should be more precise. ATM the description of `starts_line` is line started by this opcode (if any), otherwise None I think "source line started ..." would be a bit more precise an

[issue39823] Disassembly - improve documentation for bytecode instruction class and set source line no. attribute for every instruction

2020-03-02 Thread S Murthy
New submission from S Murthy : I note that on disassembling a piece of source code (via source strings or code objects) the corresponding sequence of bytecode instruction objects (https://docs.python.org/3/library/dis.html#dis.Instruction) do not always have the `starts_line` attribute set

[issue39800] Inconsistent/incomplete disassembly of methods vs method source code

2020-02-29 Thread S Murthy
S Murthy added the comment: Yes, I know that a method body may contain more than just the return statement - I was referrring to the byte code for the method def f(x): return x**2. I don't think the output of dis.dis is correct here for the source string of f - it doesn't make

[issue39800] Inconsistent/incomplete disassembly of methods vs method source code

2020-02-29 Thread S Murthy
S Murthy added the comment: BTW how else are methods/functions are created in Python except via def? -- ___ Python tracker <https://bugs.python.org/issue39

[issue39800] Inconsistent/incomplete disassembly of methods vs method source code

2020-02-29 Thread S Murthy
S Murthy added the comment: @steven.daprano In this case, the method f was created by via def. And calling dis.dis(s) where s is the source code of f (say s = inspect.getsource(f)) shows the bytecode both for the header and the body, as is clear enough from the example I first posted

[issue39800] Inconsistent/incomplete disassembly of methods vs method source code

2020-02-29 Thread S Murthy
New submission from S Murthy : I am using the dis module to look at source (and logical) lines of code vs corresponding bytecode instructions. I am bit confused by the output of dis.dis when disassembling a given method vs the corresponding source string, e.g. >>> def f(x): re