python how to get iobytes allocated memory length?

后端 未结 3 1887
遇见更好的自我
遇见更好的自我 2020-12-29 04:30

This is the code i am using to test the memory allocation

import pycurl
import io


url = \"http://www.stackoverflow.com\"
buf = io.BytesIO()


print(len(bu         


        
3条回答
  •  长情又很酷
    2020-12-29 04:57

    io.BytesIO() returns a standard file object which has function tell(). It reports the current descriptor position and does not copy the whole buffer out to compute total size as len(bio.getvalue()) of bio.getbuffer().nbytes. It is a very fast and simple method to get the exact size of used memory in the buffer object.

    I posted an example code and a more detailed answer here

提交回复
热议问题