Write a bytes-like object *data* to the file. Returns the number of uncompressed bytes written, which is always the length of data in bytes. Note that due to buffering, the file on disk may not reflect the data written until .flush() or .close() is called.
(self, data, /)
| 119 | self._close_fp = False |
| 120 | |
| 121 | def write(self, data, /): |
| 122 | """Write a bytes-like object *data* to the file. |
| 123 | |
| 124 | Returns the number of uncompressed bytes written, which is |
| 125 | always the length of data in bytes. Note that due to buffering, |
| 126 | the file on disk may not reflect the data written until .flush() |
| 127 | or .close() is called. |
| 128 | """ |
| 129 | self._check_can_write() |
| 130 | |
| 131 | length = _nbytes(data) |
| 132 | |
| 133 | compressed = self._compressor.compress(data) |
| 134 | self._fp.write(compressed) |
| 135 | self._pos += length |
| 136 | return length |
| 137 | |
| 138 | def flush(self, mode=FLUSH_BLOCK): |
| 139 | """Flush remaining data to the underlying stream. |