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:
adrianeboyd 2020-02-16 17:19:41 +01:00 committed by GitHub
parent 5b102963bf
commit 0c47a53b5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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: