Giter Site home page Giter Site logo

Python 3 support about pyinstrument HOT 4 CLOSED

joerick avatar joerick commented on May 9, 2024
Python 3 support

from pyinstrument.

Comments (4)

joerick avatar joerick commented on May 9, 2024

Hi @asmeurer,

I don't use Python 3 myself yet on any of my projects, but I'm keen to see it succeed so I'd like to support Python 3 if we can. I don't much like the 2to3 approach i.e. maintaining two codebases or having one generated from the other, so I'm more inclined to look six. If I can avoid including that, though, I will, since it's a pretty small project it might not need it.

After a quick look I can see the following things:

  • use of iteritems in profiler.py:123
  • use of exec in main.py:41
  • possibly some string/byte confusion with the ANSI colors

so hopefully it'll be fairly straightforward.

from pyinstrument.

asmeurer avatar asmeurer commented on May 9, 2024

Yes, I think writing a compatible code-base without 2to3 or six in your case will be pretty easy. I would recommend not supporting Python 3.2, so that you can keep the unicode literals.

I ran the code through 2to3 and successfully used it, so that means that there shouldn't be many issues aside from the ones that it picks up. So I would just run 2to3 and then go through the diff and fix things to be cross compatible rather than Python 3-only compatible.

from pyinstrument.

asmeurer avatar asmeurer commented on May 9, 2024

Here is what the 2to3 result looks like https://github.com/asmeurer/pyinstrument/compare/2to3?expand=1. I'll probably just do the whole port right now. This tool has helped me a lot today. I think you deserve it.

from pyinstrument.

asmeurer avatar asmeurer commented on May 9, 2024

By the way, you totally had a typo. except SystemExit, KeyboardInterrupt uses KeyboardInterrupt as the name for the caught SystemExit exception. You want except (SystemExit, KeyboardInterrupt). Fortunately, Python 3 disallows this mistake.

from pyinstrument.

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.