File Read Cache - How to purge?

Nick Craig-Wood nick at craig-wood.com
Tue Aug 21 14:30:06 EDT 2007


Wolfgang Draxinger <wdraxinger at darkstargames.de> wrote:
>  Marc 'BlackJack' Rintsch wrote:
> 
> > You mean reading the file without actually reading it!?  :-)
> 
>  Linux provides its specific syscall 'readahead' that does exactly
>  this.

It isn't in the posix module, but you can use it with ctypes like this

    >>> from ctypes import *
    >>> libc = CDLL("libc.so.6")
    >>> libc.readahead
    <_FuncPtr object at 0xb7de9714>
    >>> f=open("z","rb")
    >>> f.fileno()
    3
    >>> libc.readahead(f.fileno(), 0, 0x1000000)
    0
    >>> 

(That example could do with more ctypes magic to set the types and the
return type of readahead...)

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list