compare-the-speed-of-grep-with-python-regex.txt: Clean up and expand#119
Open
mfwitten wants to merge 13 commits intoszabgab:mainfrom
Open
compare-the-speed-of-grep-with-python-regex.txt: Clean up and expand#119mfwitten wants to merge 13 commits intoszabgab:mainfrom
mfwitten wants to merge 13 commits intoszabgab:mainfrom
Conversation
While reading the article, this is how I wish it had been presented.
* For a better initial comparison, the pyhon code has been
altered to match the bash code as closely as possible; a
function named 'grep' is used to simulate a call to the
program 'grep'.
* Next, a couple of a new Python code files have been
introduced:
examples/grep_speed-open-once.py
examples/grep_speed-optimized.py
In particular:
* grep_speed-open-once.py: This simply alters the Python
code to ensure that the file is opened only once, using
'seek' to return to the beginning of the file on each
iteration.
* grep_speed-optimized.py: In addition, this one compiles
the regular expression only once, which significantly
improves the performance, but the results are still
very slow.
* The article text has been updated to reflect these changes;
I also used my timing results to make sure that things are
consistent.
* The optimized Python code is discussed initially. * The unoptimized Python code is discussed next. * The timing has been updated to reflect what I'm seeing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch series does the following:
Fixes typos and grammar.
Makes comparisons more consistent.
Constructs optimized Python code in steps.
However:
The git history has already been designed to clearly delineate this patch:
You may want to update the Perl version of this page, which is what prompted this work in the first place; if I recall correctly,
perltries to compile regular expressions only once when possible, and so you may be comparing apples and oranges there.In addition, this is a one-off PR; I will not be making any improvements to my patch series, so if you want to use my work, please apply this series and then add your changes on top as you see fit.