summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemi Chateauneu <remi.chateauneu@gmail.com>2021-05-18 12:05:05 +0100
committerRemi Chateauneu <remi.chateauneu@gmail.com>2021-05-18 12:05:05 +0100
commit282a8b779b9974ff8f449dee8ebb8165d0555dd9 (patch)
treeb1062e189d96b0097af7c10d530ebcb33eacfb2c
parenta9aaef18c86f4bb645ee791a50c805bf0d9cecd0 (diff)
downloadrdflib-282a8b779b9974ff8f449dee8ebb8165d0555dd9.tar.gz
Speedup Literal.__hash__ and Literal.__eq__ by accessing directly _datatype and _language.
-rw-r--r--rdflib/term.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/rdflib/term.py b/rdflib/term.py
index 0f627e69..4e7c3c82 100644
--- a/rdflib/term.py
+++ b/rdflib/term.py
@@ -969,10 +969,10 @@ class Literal(Identifier):
"""
# don't use super()... for efficiency reasons, see Identifier.__hash__
res = str.__hash__(self)
- if self.language:
- res ^= hash(self.language.lower())
- if self.datatype:
- res ^= hash(self.datatype)
+ if self._language:
+ res ^= hash(self._language.lower())
+ if self._datatype:
+ res ^= hash(self._datatype)
return res
def __eq__(self, other):
@@ -1017,9 +1017,9 @@ class Literal(Identifier):
return False
if isinstance(other, Literal):
return (
- self.datatype == other.datatype
- and (self.language.lower() if self.language else None)
- == (other.language.lower() if other.language else None)
+ self._datatype == other._datatype
+ and (self._language.lower() if self._language else None)
+ == (other._language.lower() if other._language else None)
and str.__eq__(self, other)
)