Code Monkey home page Code Monkey logo

Comments (5)

myint avatar myint commented on May 19, 2024

I explored bytecode comparison when I first wrote the acid tests. I gave up on it once I found that things like has_key() and in didn't collapse into the same bytecode. But since autopep8 is now doing things a bit more complicated like shortening lines, it might be worth doing what you suggest. I suppose we would need to disable everything except whitespace, indentation, and line length changes.

By the way, the idiomatic changes I mention are basically the things 2to3 -f idioms fixes.

from autopep8.

myint avatar myint commented on May 19, 2024

See 8631ecb.

from autopep8.

myint avatar myint commented on May 19, 2024

I should probably do a recursive comparison of the code object rather than using dis. My current implementation with dis is basically just checking the top-level bytecode.

from autopep8.

myint avatar myint commented on May 19, 2024

For the most part, this works well. But sometimes the same code section generates different, but equivalent, bytecode representations. For example

16 LOAD_CONST             338 ((('catalogue', '0001_initial'), ('customer', '0001_initial'), ('partner', '0001_initial'), ('address', '0001_initial')))

versus

16 LOAD_CONST               1 ('catalogue')
19 LOAD_CONST               2 ('0001_initial')
22 BUILD_TUPLE              2
25 LOAD_CONST               3 ('customer')
28 LOAD_CONST               2 ('0001_initial')
31 BUILD_TUPLE              2
34 LOAD_CONST               4 ('partner')
37 LOAD_CONST               2 ('0001_initial')
40 BUILD_TUPLE              2
43 LOAD_CONST               5 ('address')
46 LOAD_CONST               2 ('0001_initial')
49 BUILD_TUPLE              2
52 BUILD_TUPLE              4

from autopep8.

myint avatar myint commented on May 19, 2024

Comparing the AST works better.

from autopep8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.