Skip to content

Slow greedy regex #112

Open
Open
@danielhollas

Description

@danielhollas

Greedily matching numbers in F90_CONSTANTS_TYPES_RE is super slow for numbers with many digits.

https://github.com/pseewald/fprettify/blob/cb254022c2034ad3b8f744f4dad1bf5b7438815d/fprettify/__init__.py#L475

Kudos to @Jellby and @zaikunzhang for independently discovering this and fixing it as part of their PRs in
2f766f3 and bf41457, respectively.

Since those PRs are not yet merged, I am documenting the issue here for clarity. As one data point, parsing one file with 600 lines containing a lot of numbers went from 12s to 1s after the fix!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions