Comments (16)
User (CPU) time running over first example above, measured at every yapf commit:
from yapf.
Perhaps this/these should be added as a (timed) test?
from yapf.
Quite alright. :-) It's good to know where we're doing less than good.
from yapf.
@campos-ddc I believe this is no longer an issue. Any new slow examples should file new bugs. :-)
from yapf.
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.
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.
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.
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.
OP issue now takes less than 2.5 seconds on my laptop. I guess some optimization was done along the way.
from yapf.
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.
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.
@w0rp see the --lines
switch. It should allow you to run the common case in milliseconds when changes are precisely pointed to.
from yapf.
Even with --lines
, yapf
can take a few seconds to execute on some of my source files.
from yapf.
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.
@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.
Is this still an issue? Takes 0.611 seconds in my machine.
from yapf.
Related Issues (20)
- How to avoid line break before comparison operator? HOT 1
- How to keep as many function arguments on each same line as possible? HOT 1
- Adding support for balanced line breaks? HOT 2
- Incorrect dict indentation inside nested context? HOT 5
- Support 3.12 feature: PEP 695 Type Parameter Syntax
- May I ask how to automatically add a space after "#" when using yapf? I haven't found such configuration. Thank you. HOT 2
- Format long list of lists HOT 1
- SPACE_INSIDE_BRACKETS does not work for closing curly bracket HOT 1
- Format error when async method after comment
- Crash when parsing function with unexpected await
- yapf: input filenames did not match any python files - VS code, formatting doesn't work HOT 1
- `NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS` crashes yapf when configured with `%`
- Broken parser: `case` is a valid variable name
- [Bug] Some space out of range strip when using `-l` argument. HOT 2
- The NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS format option doesn't work correctly.
- Remove the blank line between docstring and function head
- Improve error reporting when `yapf` encounters unsupported Python syntax
- Set specific options for keywords
- Function call without arguments.
- Yapf not formatting python generic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yapf.