Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove OrderedDict from re module
  • Loading branch information
srinivasreddy committed Dec 26, 2017
commit 5049a81628147e5e2855a80eea1d170e25538460
10 changes: 2 additions & 8 deletions Lib/re.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@
except ImportError:
_locale = None

# try _collections first to reduce startup cost
try:
from _collections import OrderedDict
except ImportError:
from collections import OrderedDict


# public symbols
__all__ = [
Expand Down Expand Up @@ -271,7 +265,7 @@ def escape(pattern):
# --------------------------------------------------------------------
# internals

_cache = OrderedDict()
_cache = {}

_MAXCACHE = 512
def _compile(pattern, flags):
Expand All @@ -293,7 +287,7 @@ def _compile(pattern, flags):
if not (flags & DEBUG):
if len(_cache) >= _MAXCACHE:
try:
_cache.popitem(last=False)
_cache.pop(list(_cache.keys())[0])
except KeyError:
pass
_cache[type(pattern), pattern, flags] = p
Expand Down