Method: gzip.GzipFile.write
Calls: 314, Exceptions: 3, Paths: 5Back
Path 1: 301 calls (0.96)
bytes (300) bytearray (1)
1 (201) 6050 (30) 121 (21) 3 (17) 13 (15) 142 (10) 31 (2) 2130 (1) 2000000 (1) 24200 (1)
1def write(self,data):
2 self._check_not_closed()
3 if self.mode != WRITE:
4 import errno
5 raise OSError(errno.EBADF, "write() on read-only GzipFile object")
6
7 if self.fileobj is None:
8 raise ValueError("write() on closed GzipFile object")
9
10 if isinstance(data, (bytes, bytearray)):
11 length = len(data)
12 else:
13 # accept any data that supports the buffer protocol
14 data = memoryview(data)
15 length = data.nbytes
16
17 if length > 0:
18 self.fileobj.write(self.compress.compress(data))
19 self.size += length
20 self.crc = zlib.crc32(data, self.crc)
21 self.offset += length
22
23 return length
Path 2: 6 calls (0.02)
bytes (6)
0 (6)
1def write(self,data):
2 self._check_not_closed()
3 if self.mode != WRITE:
4 import errno
5 raise OSError(errno.EBADF, "write() on read-only GzipFile object")
6
7 if self.fileobj is None:
8 raise ValueError("write() on closed GzipFile object")
9
10 if isinstance(data, (bytes, bytearray)):
11 length = len(data)
12 else:
13 # accept any data that supports the buffer protocol
14 data = memoryview(data)
15 length = data.nbytes
16
17 if length > 0:
18 self.fileobj.write(self.compress.compress(data))
19 self.size += length
20 self.crc = zlib.crc32(data, self.crc)
21 self.offset += length
22
23 return length
Path 3: 4 calls (0.01)
array (2) memoryview (2)
40 (1) 4840 (1) 6050 (1) 256 (1)
1def write(self,data):
2 self._check_not_closed()
3 if self.mode != WRITE:
4 import errno
5 raise OSError(errno.EBADF, "write() on read-only GzipFile object")
6
7 if self.fileobj is None:
8 raise ValueError("write() on closed GzipFile object")
9
10 if isinstance(data, (bytes, bytearray)):
11 length = len(data)
12 else:
13 # accept any data that supports the buffer protocol
14 data = memoryview(data)
15 length = data.nbytes
16
17 if length > 0:
18 self.fileobj.write(self.compress.compress(data))
19 self.size += length
20 self.crc = zlib.crc32(data, self.crc)
21 self.offset += length
22
23 return length
Path 4: 2 calls (0.01)
'' (1) [] (1)
TypeError (2)
1def write(self,data):
2 self._check_not_closed()
3 if self.mode != WRITE:
4 import errno
5 raise OSError(errno.EBADF, "write() on read-only GzipFile object")
6
7 if self.fileobj is None:
8 raise ValueError("write() on closed GzipFile object")
9
10 if isinstance(data, (bytes, bytearray)):
11 length = len(data)
12 else:
13 # accept any data that supports the buffer protocol
14 data = memoryview(data)
15 length = data.nbytes
16
17 if length > 0:
18 self.fileobj.write(self.compress.compress(data))
19 self.size += length
20 self.crc = zlib.crc32(data, self.crc)
21 self.offset += length
22
23 return length
Path 5: 1 calls (0.0)
bytes (1)
ValueError (1)
1def write(self,data):
2 self._check_not_closed()
3 if self.mode != WRITE:
4 import errno
5 raise OSError(errno.EBADF, "write() on read-only GzipFile object")
6
7 if self.fileobj is None:
8 raise ValueError("write() on closed GzipFile object")
9
10 if isinstance(data, (bytes, bytearray)):
11 length = len(data)
12 else:
13 # accept any data that supports the buffer protocol
14 data = memoryview(data)
15 length = data.nbytes
16
17 if length > 0:
18 self.fileobj.write(self.compress.compress(data))
19 self.size += length
20 self.crc = zlib.crc32(data, self.crc)
21 self.offset += length
22
23 return length