Skip to content

Commit

Permalink
Replace use of 'long' type in premap_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
honnibal committed Oct 1, 2024
1 parent 78092ac commit a855945
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions thinc/layers/premap_ids.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# cython: binding=True, infer_types=True, profile=False
from libc.stdint cimport int64_t
import numpy

from preshed.maps cimport PreshMap
Expand All @@ -14,15 +15,15 @@ InT = Union[Ints1d, Ints2d]
OutT = Ints2d


cdef lookup(PreshMap mapping, long[:] keys, long default):
cdef lookup(PreshMap mapping, int64_t[:] keys, int64_t default):
"""
Faster dict.get(keys, default) for the case when
the "dict" is a Dict[int, int] converted to PreshMap
and the "keys" is a numpy integer vector.
"""
cdef int maxi = len(keys)
result = numpy.empty(maxi, dtype="int")
cdef long[:] result_view = result
cdef int64_t[:] result_view = result
for i in range(maxi):
v = mapping[keys[i]]
if v is None:
Expand Down

0 comments on commit a855945

Please sign in to comment.