Comments (9)
Oh -- I am running Python 2.7.1.
from pydocstyle.
This can be reproduced from command line. Execution took 17 seconds with:
$ ../bin/pep257 rewind/*.py rewind/test/*.py
from pydocstyle.
Oh, and one last thing, if you would like me to publish my current pep257 branch for you to reproduce this, I can do that.
from pydocstyle.
Just looking at the code it seems like parse_methods(...)
might be called many times with the same arguments in parse_contexts(...)
(and takes account for 17 seconds of execution). Refactoring so that each source is parsed only once and having the results cached, one might decrease the time spent in that function a lot. This could possibly be done by implementing something similar to this or this.
from pydocstyle.
This is what the profiling result looks like after the changes that pull request #12 introduces:
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.002 0.002 6.025 6.025 pep257.py:67(<module>)
1 0.003 0.003 5.996 5.996 pep257.py:366(main)
190/6 0.001 0.000 5.991 0.999 pep257.py:130(<lambda>)
118 0.008 0.000 5.991 0.051 pep257.py:323(check_source)
96 0.000 0.000 4.988 0.052 pep257.py:242(parse_contexts)
533 0.180 0.000 4.269 0.008 pep257.py:188(parse_top_level)
1264 1.169 0.001 3.480 0.003 StringIO.py:168(readlines)
1040 0.007 0.000 2.894 0.003 pep257.py:137(abs_pos)
65 0.000 0.000 2.495 0.038 pep257.py:208(parse_classes)
1152457 1.685 0.000 2.222 0.000 StringIO.py:139(readline)
331865 1.060 0.000 2.033 0.000 tokenize.py:264(generate_tokens)
314711 0.080 0.000 2.022 0.000 {next}
78 0.000 0.000 1.774 0.023 pep257.py:204(parse_functions)
78 0.000 0.000 0.944 0.012 pep257.py:118(cached_func)
135 0.003 0.000 0.944 0.007 pep257.py:226(parse_methods)
309500 0.771 0.000 0.771 0.000 {built-in method match}
112 0.002 0.000 0.707 0.006 pep257.py:278(__init__)
224 0.060 0.000 0.703 0.003 pep257.py:144(rel_pos)
1152693 0.362 0.000 0.362 0.000 {method 'find' of 'str' objects}
2108 0.018 0.000 0.200 0.000 pep257.py:172(parse_docstring)
from pydocstyle.
Every file checked generates two calls to parse_functions(...)
, parse_classes(...)
and parse_methods(...)
through parse_contexts(...)
. By caching those results whenever possible a one would be able to gain 2.495/2+1.774/2+ 0.944/2=2.59
seconds more in the example above.
from pydocstyle.
Every file checked generates two calls to
parse_functions(...)
,parse_classes(...)
andparse_methods(...)
throughparse_contexts(...)
. By caching those results whenever possible a one would be able to gain2.495/2+1.774/2+ 0.944/2=2.59
seconds more in the example above.
This fix was added in pull request #12.
from pydocstyle.
#12 is merged now. pep257 is probably still 10 times slower than it could be, but good enough for now.
If you come up with more speed improvements—you are welcome!
from pydocstyle.
#12 is merged now. pep257 is probably still 10 times slower than it could be, but good enough for now.
I agree, but works for now!
If you come up with more speed improvements—you are welcome!
Sure! But for now it doesn't hinder me in running my tests.
from pydocstyle.
Related Issues (20)
- option to ban `noqa` comments that don't specify a code
- D102 - false positive on overload with comment
- cosmetic bug: wrong version stamp in webpage title: 1.0.0 instead of 2.1.1
- The match-dir parameter is not used. HOT 4
- Not detecting wrong DocStrings HOT 1
- Your website is down - https://pydocstyle.org HOT 3
- Crash with simple f-string HOT 7
- Docs website is down? HOT 1
- sdist: PKG-INFO should list LICENSE-MIT in License-File
- `D300` and `D301` false positives on docstrings with escaped triple quotes in them
- Should `__main__.py` really be considered a public module?
- Option to not report error for empty file HOT 1
- test_simple_fstring and test_fstring_with_args fail with Python 3.12 beta HOT 2
- 6.3.0: incorrect version in pyproject.toml?🤔 HOT 2
- pydocstyle 6.3.0 fails silently on a python script that has no .py extension
- Rule for missing PEP 698 `@overrides` decorators?
- Keyword Args not recognized in Google convention with no return
- Python3.12: Two tests fail HOT 1
- Google convention section names not properly checked
- D417 not raised in a standard Google configuration with missing arguments descriptions
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 pydocstyle.