En Thu, 29 May 2008 19:17:05 -0300, Kris Kennaway <kris@FreeBSD.o rg>
escribió:
Looks like you should define the sq_contains member in mmap_as_sequenc e,
and the type should have the Py_TPFLAGS_HAVE _SEQUENCE_IN flag set (all in
mmapmodule.c)
--
Gabriel Genellina
escribió:
If I do the following:
>
def mmap_search(f, string):
fh = file(f)
mm = mmap.mmap(fh.fi leno(), 0, mmap.MAP_SHARED , mmap.PROT_READ)
>
return mm.find(string)
>
def mmap_is_in(f, string):
fh = file(f)
mm = mmap.mmap(fh.fi leno(), 0, mmap.MAP_SHARED , mmap.PROT_READ)
>
return string in mm
>
then a sample mmap_search() call on a 50MB file takes 0.18 seconds, but
the mmap_is_in() call takes 6.6 seconds. Is the mmap class missing an
operator and falling back to a slow default implementation? Presumably
I can implement the latter in terms of the former.
>
def mmap_search(f, string):
fh = file(f)
mm = mmap.mmap(fh.fi leno(), 0, mmap.MAP_SHARED , mmap.PROT_READ)
>
return mm.find(string)
>
def mmap_is_in(f, string):
fh = file(f)
mm = mmap.mmap(fh.fi leno(), 0, mmap.MAP_SHARED , mmap.PROT_READ)
>
return string in mm
>
then a sample mmap_search() call on a 50MB file takes 0.18 seconds, but
the mmap_is_in() call takes 6.6 seconds. Is the mmap class missing an
operator and falling back to a slow default implementation? Presumably
I can implement the latter in terms of the former.
and the type should have the Py_TPFLAGS_HAVE _SEQUENCE_IN flag set (all in
mmapmodule.c)
--
Gabriel Genellina