question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement optimizer module

See original GitHub issue

Optimizer module should transform a regular expression into an optimized version, replacing some sub-expressions with their idiomatic patterns. This might be good for different kinds of minifiers, as well as for regexp machines.

Example:

/[a-zA-Z_0-9][a-zA-Z_0-9]*\e{1,}/

Is transformed into:

/\w+e+/

We can implement the optimizer as a set of small transforms (this depends on issue #7, and issue #23).

Patterns to replace:

  • aa* -> a+
  • (), (?:) - <empty> (remove empty groups)
  • a{1,} -> a+
  • a{1} -> a
  • a{3,3} -> a{3}
  • [a-zA-Z_0-9] -> \w
  • [^a-zA-Z_0-9] -> \W
  • [\d\d] -> [\d] (remove duplicates from char-class)
  • [\d] -> \d (remove char class for single char)
  • [0-9] -> \d
  • [^0-9] -> \D
  • [ \t\r\n\f] -> \s
  • [^ \t\r\n\f] -> \S
  • \e -> e (remove unnecessary escape)

See TODO item, optimizer lives in src/optimizer.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mathiasbynenscommented, Mar 30, 2017

Keep in mind that the u flag (or the combination of the u and i flag) impacts some of these transformations.

0reactions
DmitrySoshnikovcommented, Apr 13, 2017

Closing this one since the module is set up. Other specific transforms can be implemented in separate issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write an optimizer — ppci 0.5.9 documentation
To implement an optimalisation, the ppci.opt.transform.ModulePass must be subclassed. For this example, ppci.opt.transform.InstructionPass will be used.
Read more >
Optimization - Hugging Face
The .optimization module provides: an optimizer with weight decay fixed that can be used to fine-tuned models, and; several schedules in the form...
Read more >
The Optimization Module User's Guide
COMSOL products. This guide is a supplement to the COMSOL Multiphysics. Reference Manual. In this section is a short Optimization Module Overview.
Read more >
Optimization - webpack
Tells webpack which algorithm to use when choosing module ids. Setting optimization.moduleIds to false tells webpack that none of built-in algorithms should ...
Read more >
How to use Pytorch as a general optimizer | by Conor Mc.
Next, let's define the model and the training loop: class Model(nn.Module): """Custom Pytorch model for gradient optimization. """ def __init__( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found