On the new `regex` module

Do we need to copy Python API here? This API is:

  • inconsistent (flatcase fullmatch)
  • unnecessary abbreviated (sub - substitute - this one is also inconsistent with string.replace() which purpose is the same)
  • far away from SotA implementation.

I propose:

  1. Dropping Python names and picking self-explanatory and consistent ones. Support for Python API could be added later via extensions and re module. This way we avoid same names with changes in behavior
  2. Considering implementations in other system level langs like Rust / Zig to prioritize performance

@joe @adakkak

1 Like

Another case to consider. Do free functions at module level work well? I am not sure with current implementation. Consider Python code:

from re import sub

sub('foo+', 'foo', text)

At first glance it is not obvious for what sub is referring to. It only has sense with module name itself:

import re

re.sub('foo+', 'foo', text)

This module has been removed. I am fine with it. It is better to provide regex handling in the future in a good state from the beginning rather than half baked Python-like API to just have something