mirror of https://github.com/explosion/spaCy.git
Use int only in key2row for better performance (#4990)
Cast all keys and rows to `int` in `vectors.key2row` for more efficient access and serialization.
This commit is contained in:
parent
5b102963bf
commit
0c47a53b5e
|
@ -283,7 +283,11 @@ cdef class Vectors:
|
||||||
|
|
||||||
DOCS: https://spacy.io/api/vectors#add
|
DOCS: https://spacy.io/api/vectors#add
|
||||||
"""
|
"""
|
||||||
key = get_string_id(key)
|
# use int for all keys and rows in key2row for more efficient access
|
||||||
|
# and serialization
|
||||||
|
key = int(get_string_id(key))
|
||||||
|
if row is not None:
|
||||||
|
row = int(row)
|
||||||
if row is None and key in self.key2row:
|
if row is None and key in self.key2row:
|
||||||
row = self.key2row[key]
|
row = self.key2row[key]
|
||||||
elif row is None:
|
elif row is None:
|
||||||
|
|
Loading…
Reference in New Issue