Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make normalize_whitespace faster #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Make normalize_whitespace faster #31

wants to merge 3 commits into from

Conversation

pictuga
Copy link

@pictuga pictuga commented Apr 7, 2015

This had significant consequences on a program of mine.

Before:

real    0m5.776s
user    0m4.150s
sys 0m0.077s

After:

real    0m4.261s
user    0m4.130s
sys 0m0.073s

(That's more than a second difference!)

(breadability is called on ± 30 pages during my script execution)

This drops the distinction between \n and whitespaces, but from what I've understood, this distinction is actually not used in the code after.

pictuga added 3 commits April 7, 2015 17:52
A mostly-similar result can be achieved much faster. The only difference is that it doesn't care whether there's a line break in the string.
normalize_whitespace does the job as well
@miso-belica
Copy link
Member

I think you should look at user time.

And your solution doesn't preserve new lines which may be significant for someone (e.g. for me :). It's great to have code fast but it should work in the first place :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants