title: Pass file handle to cython function
body: <p>I want to compile a python function with cython, for reading a binary file skipping some records (without reading the whole file and then slicing, as I would run out of memory). I can come up with something like this:</p>
  
  <pre><code>    def FromFileSkip(fid, count=1, skip=0):            
          if skip&gt;=0:
              data = numpy.zeros(count)
              k = 0
              while k&lt;count:
                  try:
                      data[k] = numpy.fromfile(fid, count=1, dtype=dtype)
                      fid.seek(skip, 1)
                      k +=1
                  except ValueError:
                      data = data[:k]
                      break
              return data
  </code></pre>
  
  <p>and then I can use the function like this:</p>
  
  <pre><code> f = open(filename)
   data = FromFileSkip(f,...
  </code></pre>
  
  <p>However, for compiling the function "FromFileSkip" with cython, I would like to define all the types involved in the function, so "fid" as well, the file handler. How can I define its type in cython, as it is not a "standard" type, e.g. an integer.
  Thanks.</p>