[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions about the IO modules and C-api

I have some questions about the IO modules.

1. My script:

    f = open('myfile, 'a+b')

I added a printf statement at the beginning of _io_open_impl
the output is:


Why this function has been called more than one time? I expect this
function only let us call the `open()` system call once.

2. I'm not familiar with the C, How the c-api like
_PyIO_str_write, memobj, NULL)

I guess this function will finally call the `write()` system call but I
don't know why it would work. I found `self->raw` is an empty PyObject and
`_PyIO_str_write` is a global variable which is NULL.  Why an empty
PyObject have a write method? Why we didn't just use `write()` system call

Thank you so much :D