Git Product home page Git Product logo

Comments (16)

chkno avatar chkno commented on May 7, 2024 8

User (CPU) time running over first example above, measured at every yapf commit:
yapf-speed

from yapf.

hayd avatar hayd commented on May 7, 2024 2

Perhaps this/these should be added as a (timed) test?

from yapf.

bwendling avatar bwendling commented on May 7, 2024 1

Quite alright. :-) It's good to know where we're doing less than good.

from yapf.

bwendling avatar bwendling commented on May 7, 2024 1

@campos-ddc I believe this is no longer an issue. Any new slow examples should file new bugs. :-)

from yapf.

bwendling avatar bwendling commented on May 7, 2024

Oof...Yeah, this is because it's trying all combinations of newlines for this data literal. (This is also a good test for a heuristic that I put into YAPF.) In the meantime, you could put a "# yapf: disable" at the end of the data literal so that we won't mess up the formatting:

FOO = frozenset((
1,
...
)) # yapf: disable

from yapf.

DRMacIver avatar DRMacIver commented on May 7, 2024

I confess this example doesn't actually come from my code, so I'm not in immediate need of working around it. I'm just experimenting at this point.

from yapf.

DRMacIver avatar DRMacIver commented on May 7, 2024

Here is a possibly related example which is instead pathological in space: https://gist.github.com/DRMacIver/8c2a4c3fdbb923c4a27c

It takes more than 100MB to run (and is extracted from an example only about 4 times larger that crashed when it hit my default 2GB ulimit)

from yapf.

lins05 avatar lins05 commented on May 7, 2024

Here is another example that's very slow to format:

answers = [
    ('', ''),
    # 1
    ('', ''),
    # 2
    ('', ''),
    # 3
    ('', ''),
    # 4
    ('', ''),
    # 5
    ('', ''),
    # 6
    ('', ''),
]

It feels like the time grows exponentially with the items in this array.

from yapf.

ppolewicz avatar ppolewicz commented on May 7, 2024

OP issue now takes less than 2.5 seconds on my laptop. I guess some optimization was done along the way.

from yapf.

bwendling avatar bwendling commented on May 7, 2024

That isn't a bad idea. I've not set up Python performance tests before. Any thoughts on the best way to do this? (I assume it involves the timeit module somehow.)

from yapf.

w0rp avatar w0rp commented on May 7, 2024

I would like to see some more work on improving the performance of this tool. I tried it out for the first time today, and for the most part the formatting seems to be pretty good. yapf currently takes a few seconds at a time to format most of the files in the codebase I work on primarily these days. If that time could be reduced to sub-second speeds, then yapf could be used for automatically formatting Python code in Vim pretty well.

from yapf.

ppolewicz avatar ppolewicz commented on May 7, 2024

@w0rp see the --lines switch. It should allow you to run the common case in milliseconds when changes are precisely pointed to.

from yapf.

w0rp avatar w0rp commented on May 7, 2024

Even with --lines, yapf can take a few seconds to execute on some of my source files.

from yapf.

ppolewicz avatar ppolewicz commented on May 7, 2024

Oh. Please create a new issue for this, including configuration,
commandline arguments and code.

04.09.2016 15:17 "w0rp" [email protected] napisaล‚(a):

Even with --lines, yapf can take a few seconds to execute on some of my
source files.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#39 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAsWGdsTGDsBUy63hI1O8PNtRGN0rvwRks5qmsTPgaJpZM4D1egy
.

from yapf.

bwendling avatar bwendling commented on May 7, 2024

@w0rp Yes, please file a new issue for that. It may be another pathological example that we should optimize for.

Performance is more of a journey than a goal. There will always be ways to do things better. :-) So having an issue open for performance isn't great. It's better to have them for pathological examples.

from yapf.

campos-ddc avatar campos-ddc commented on May 7, 2024

Is this still an issue? Takes 0.611 seconds in my machine.

from yapf.

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.