Porting Python 2 code that uses _multiprocessing
Question: I'm currently porting some Python 2 code that was being run with pypy over to
python 3. I'm a bit stuck with dealing with some code that uses
`_multiprocessing` as the documentation is hard to find for this.

    
    
    from _multiprocessing import address_of_buffer
    #example usage
    def buffer_info(self):
        return address_of_buffer(self._mmap)[0], self._size
    

When I attempt to use this code into Python3.4 I get a problem with the
import:

    
    
    ImportError: cannot import name 'address_of_buffer'
    

After having a quick look at the Python 3 docs
<https://docs.python.org/3/library/multiprocessing.html> I'm not seeing a
direct replacement for this. What is the best way to port this code?


Answer: You can use ctypes:

    
    
    def address_of_buffer(buf):
        return ctypes.addressof(ctypes.c_char.from_buffer(buf))
    

