This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document annotation option to pickletools.dis
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: alexandre.vassalotti, belopolsky, ezio.melotti, lemburg, mark.dickinson, pitrou
Priority: normal Keywords: easy, patch

Created on 2010-07-15 19:37 by belopolsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pickletools-annotate.diff belopolsky, 2010-07-15 19:37 Patch for py3k branch, revision 82911. review
Messages (7)
msg110388 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-15 19:37
Example:

>>> dis(pickle.dumps(T, 3), annotate=1)                                                                                                                                         
    0: \x80 PROTO      3 | Protocol version indicator.                                                                                                                          
    2: ]    EMPTY_LIST   | Push an empty list.                                                                                                                                  
    3: q    BINPUT     0 | Store the stack top into the memo.  The stack is not popped.                                                                                         
    5: h    BINGET     0 | Read an object from the memo and push it on the stack.                                                                                               
    7: \x85 TUPLE1       | One-tuple.                                                                                                                                           
    8: q    BINPUT     1 | Store the stack top into the memo.  The stack is not popped.                                                                                         
   10: a    APPEND       | Append an object to a list.                                                                                                                          
   11: 0    POP          | Discard the top stack item, shrinking the stack by one item.                                                                                         
   12: h    BINGET     1 | Read an object from the memo and push it on the stack.                                                                                               
   14: .    STOP         | Stop the unpickling machine.
msg110467 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-16 18:17
Perhaps the annotations should be wrapped at 78 chars/line, for improved readability?
msg110469 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-16 18:34
> Perhaps the annotations should be wrapped at 78 chars/line ..

I don't know.  With deeply nested pickles, annotations may not even start before column 80.  I think further improvement in alignment and layout algorithms will show diminishing returns.  If I were to invest an effort into this, I would share it with dis.dis.

You can see how larger pickles look by running pickletools -a 27.bench with a pickle from issue5180.
msg110542 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2010-07-17 08:11
LGTM
msg110568 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-17 15:56
Committed in r82931 with small changes based on comments here and on IRC:

1. Annotations are separated from disassembly by spaces without '|'.
2. Made a small improvement to the annotation alignment algorithm.  Excessively long lines do not force the rest of the annotations off the screen.
3. Added ReST documentation for the new dis() argument.  The command line behavior is still undocumented.  I am watching python-dev discussion on how it should be presented in ReST.
msg111648 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-26 17:23
Reopening as a documentation issue:

- manual entry should have a versionchanged
- use *arg* instead of 'arg'
- add a ReST entry describing -m pickletools
msg126203 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-01-13 22:00
Committed documentation changes in revision 87990.
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53514
2011-01-13 22:00:03belopolskysetstatus: open -> closed
nosy: lemburg, mark.dickinson, belopolsky, pitrou, alexandre.vassalotti, ezio.melotti
messages: + msg126203

resolution: fixed
stage: needs patch -> resolved
2010-12-01 18:40:45belopolskysettitle: Add annotation option to pickletools.dis -> Document annotation option to pickletools.dis
resolution: fixed -> (no value)
stage: resolved -> needs patch
2010-07-26 17:23:28belopolskysetstatus: closed -> open

nosy: + ezio.melotti
messages: + msg111648

components: + Documentation
2010-07-17 16:02:27belopolskysetstatus: open -> closed
resolution: fixed
stage: test needed -> resolved
2010-07-17 15:56:02belopolskysetmessages: + msg110568
2010-07-17 08:11:45alexandre.vassalottisetmessages: + msg110542
2010-07-16 18:34:34belopolskysetmessages: + msg110469
2010-07-16 18:17:58pitrousetmessages: + msg110467
2010-07-15 19:37:15belopolskycreate