python-filewrap 0.0.4.1__tar.gz → 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-filewrap
3
- Version: 0.0.4.1
3
+ Version: 0.0.5
4
4
  Summary: Python file wrappers.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-filewrap
6
6
  License: MIT
@@ -2,12 +2,13 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
- __version__ = (0, 0, 4)
5
+ __version__ = (0, 0, 5)
6
6
  __all__ = [
7
7
  "SupportsRead", "SupportsWrite",
8
8
  "bio_chunk_iter", "bio_chunk_async_iter",
9
9
  "bio_skip_iter", "bio_skip_async_iter",
10
10
  "bytes_iter_to_reader", "bytes_iter_to_async_reader",
11
+ "bytes_to_chunk_iter", "bytes_to_chunk_async_iter"
11
12
  ]
12
13
 
13
14
  from asyncio import to_thread, Lock as AsyncLock
@@ -414,3 +415,23 @@ def bytes_iter_to_async_reader(
414
415
  "__repr__": staticmethod(lambda: reprs),
415
416
  })()
416
417
 
418
+
419
+ def bytes_to_chunk_iter(
420
+ b,
421
+ /,
422
+ chunksize=1<<16,
423
+ ) -> Iterator[memoryview]:
424
+ m = memoryview(b)
425
+ for i in range(0, len(m), chunksize):
426
+ yield m[i:i+chunksize]
427
+
428
+
429
+ async def bytes_to_chunk_async_iter(
430
+ b,
431
+ /,
432
+ chunksize=1<<16,
433
+ ) -> AsyncIterator[memoryview]:
434
+ m = memoryview(b)
435
+ for i in range(0, len(m), chunksize):
436
+ yield m[i:i+chunksize]
437
+
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-filewrap"
3
- version = "0.0.4.1"
3
+ version = "0.0.5"
4
4
  description = "Python file wrappers."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"