reapply the revert made in r83875

Now the _collections is statically built, the build dependencies are in proper
order and build works fine.

Commit Log from r83874:
Issue 9396.   Apply functools.lru_cache in the place of the
random flushing cache in the re module.
3 files changed