Python's glob() (fnmatch really) translates the glob to a regular expression then uses its re library:
Seriously, though, it was a bit of an afterthought. A team at Google was |ing together a ton of regexps and came to me for something better, so I wrote RE2::Set. I'm glad it helps others too.
http://borgbackup.readthedocs.io/en/stable/usage.html#borg-h... ("Shell-style patterns, selector sh:")
It's specifically a CPython optimisation, it may (and usually will) not hold up on alternate implementations like pypy or jyton.
If PyPy or Jython want to reuse that core library code, it's on them to make whatever changes are needed to make it fast on those implementations.