# HG changeset patch # User Henry S. Thompson # Date 1739273144 0 # Node ID f88abc69f876a7bd865b9a90ea7a2413270a1697 # Parent 583baab8ca05e885f6200af52d26de90a08e94e1 convert most CCdb methods to cpdef diff -r 583baab8ca05 -r f88abc69f876 lib/python/cc/lmh/db.pxd --- a/lib/python/cc/lmh/db.pxd Tue Feb 04 11:17:13 2025 +0000 +++ b/lib/python/cc/lmh/db.pxd Tue Feb 11 11:25:44 2025 +0000 @@ -1,8 +1,11 @@ cimport cdb cdef class CCdb: cdef cdb.Cdb* _c_cdb - cdef void findstart(self) - cdef int find(self, bytes p) - cdef char[::1] init(self, int fno) + cdef char[::1] _c_mv + cpdef char[::1] init(self, int fno) + cpdef void findstart(self) + cpdef int find(self, bytes p) cdef cdb.uint32 pos(self) cdef int len(self) + cpdef long raw(self) + cpdef char[::1] value(self) diff -r 583baab8ca05 -r f88abc69f876 lib/python/cc/lmh/db.pyx --- a/lib/python/cc/lmh/db.pyx Tue Feb 04 11:17:13 2025 +0000 +++ b/lib/python/cc/lmh/db.pyx Tue Feb 11 11:25:44 2025 +0000 @@ -7,16 +7,16 @@ def __cinit__(self): self._c_cdb = cdb.cdb_new() - cdef void findstart(self): + cpdef void findstart(self): cdb.cdb_findstart(self._c_cdb) - cdef int find(self, bytes p): + cpdef int find(self, bytes p): return cdb.cdb_find(self._c_cdb, p, len(p)) - cdef char[::1] init(self, int fno): + cpdef char[::1] init(self, int fno): cdb.cdb_init(self._c_cdb,fno) - cdef char[::1] _mview = (cdb.cdb_mmap(self._c_cdb)) - return _mview + self._c_mv = (cdb.cdb_mmap(self._c_cdb)) + return self._c_mv cdef cdb.uint32 pos(self): return cdb.cdb_pos(self._c_cdb) @@ -24,5 +24,12 @@ cdef int len(self): return cdb.cdb_len(self._c_cdb) - def raw(self) -> long: + cpdef long raw(self): return (self._c_cdb) + + cpdef char[::1] value(self): + o = cdb.cdb_pos(self._c_cdb) + return self._c_mv[o: o+cdb.cdb_len(self._c_cdb)] + + + diff -r 583baab8ca05 -r f88abc69f876 lib/python/cc/lmh/nndb.pyx --- a/lib/python/cc/lmh/nndb.pyx Tue Feb 04 11:17:13 2025 +0000 +++ b/lib/python/cc/lmh/nndb.pyx Tue Feb 11 11:25:44 2025 +0000 @@ -22,6 +22,8 @@ if res == 1: print(res,o:=CC.pos(), l:=CC.len()) sys.stdout.buffer.write(mv[o:o+l]) + sys.stdout.buffer.write(b' ') + sys.stdout.buffer.write(CC.value()) sys.stdout.buffer.write(b'\n') else: print('losing %s'%res)