diff options
author | ptmcg <ptmcg@austin.rr.com> | 2021-09-02 16:33:27 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2021-09-02 16:33:27 -0500 |
commit | 1ed653a54dec0c0a81ba39139cfa4503a13fa956 (patch) | |
tree | f445fa975ee6241119a7be634c2094b7e2dcaf96 | |
parent | 19cf57e8cbfd44151bb3ca97efb5dcbfd12537aa (diff) | |
download | pyparsing-git-1ed653a54dec0c0a81ba39139cfa4503a13fa956.tar.gz |
Small perf tweaks
-rw-r--r-- | pyparsing/__init__.py | 2 | ||||
-rw-r--r-- | pyparsing/core.py | 9 | ||||
-rw-r--r-- | pyparsing/results.py | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/pyparsing/__init__.py b/pyparsing/__init__.py index 961030b..12b772a 100644 --- a/pyparsing/__init__.py +++ b/pyparsing/__init__.py @@ -103,7 +103,7 @@ __version__ = ( __version_info__.release_level == "final" ] ) -__version_time__ = "2 September 2021 17:43 UTC" +__version_time__ = "2 September 2021 21:25 UTC" __versionTime__ = __version_time__ __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" diff --git a/pyparsing/core.py b/pyparsing/core.py index cd0bcae..2f45758 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -174,7 +174,7 @@ def enable_all_warnings(): del __config_flags # build list of single arg builtins, that can be used as parse actions -_single_arg_builtins = [ +_single_arg_builtins = { sum, len, sorted, @@ -186,7 +186,7 @@ _single_arg_builtins = [ all, min, max, -] +} _generatorType = types.GeneratorType ParseAction = Union[ @@ -3095,6 +3095,7 @@ class CharsNotIn(Token): super().__init__() self.skipWhitespace = False self.notChars = not_chars or notChars + self.notCharsSet = set(self.notChars) if min < 1: raise ValueError( @@ -3125,12 +3126,12 @@ class CharsNotIn(Token): return "!W:({})".format(self.notChars) def parseImpl(self, instring, loc, doActions=True): - if instring[loc] in self.notChars: + notchars = self.notCharsSet + if instring[loc] in notchars: raise ParseException(instring, loc, self.errmsg, self) start = loc loc += 1 - notchars = self.notChars maxlen = min(start + self.maxLen, len(instring)) while loc < maxlen and instring[loc] not in notchars: loc += 1 diff --git a/pyparsing/results.py b/pyparsing/results.py index 3d52fbb..b1e5883 100644 --- a/pyparsing/results.py +++ b/pyparsing/results.py @@ -71,7 +71,7 @@ class ParseResults: - year: 1999 """ - _null_values: Tuple[Any, ...] = (None, "", [], ()) + _null_values: Tuple[Any, ...] = (None, [], "", ()) __slots__ = [ "_name", @@ -161,7 +161,7 @@ class ParseResults: self, toklist=None, name=None, asList=True, modal=True, isinstance=isinstance ): self._modal = modal - if name not in (None, ""): + if name is not None and name != "": if isinstance(name, int): name = str(name) if not modal: |