@@ -709,6 +709,19 @@ mmap__exit__method(PyObject *self, PyObject *args)
709709 return _PyObject_CallMethodId (self , & PyId_close , NULL );
710710}
711711
712+ #ifdef MS_WINDOWS
713+ static PyObject *
714+ mmap__sizeof__method (mmap_object * self , void * unused )
715+ {
716+ Py_ssize_t res ;
717+
718+ res = sizeof (mmap_object );
719+ if (self -> tagname )
720+ res += strlen (self -> tagname ) + 1 ;
721+ return PyLong_FromSsize_t (res );
722+ }
723+ #endif
724+
712725static struct PyMethodDef mmap_object_methods [] = {
713726 {"close" , (PyCFunction ) mmap_close_method , METH_NOARGS },
714727 {"find" , (PyCFunction ) mmap_find_method , METH_VARARGS },
@@ -726,6 +739,9 @@ static struct PyMethodDef mmap_object_methods[] = {
726739 {"write_byte" , (PyCFunction ) mmap_write_byte_method , METH_VARARGS },
727740 {"__enter__" , (PyCFunction ) mmap__enter__method , METH_NOARGS },
728741 {"__exit__" , (PyCFunction ) mmap__exit__method , METH_VARARGS },
742+ #ifdef MS_WINDOWS
743+ {"__sizeof__" , (PyCFunction ) mmap__sizeof__method , METH_NOARGS },
744+ #endif
729745 {NULL , NULL } /* sentinel */
730746};
731747
0 commit comments