libvalkey 4.0.1__cp313-cp313-win32.whl

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.
libvalkey/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ from libvalkey.libvalkey import Reader, LibvalkeyError, pack_command, ProtocolError, ReplyError
2
+ from libvalkey.version import __version__
3
+
4
+ __all__ = [
5
+ "Reader",
6
+ "LibvalkeyError",
7
+ "pack_command",
8
+ "ProtocolError",
9
+ "ReplyError",
10
+ "__version__"]
Binary file
@@ -0,0 +1,41 @@
1
+ from typing import Any, Callable, Optional, Union, Tuple
2
+
3
+
4
+ class LibvalkeyError(Exception):
5
+ ...
6
+
7
+
8
+ class ProtocolError(LibvalkeyError):
9
+ ...
10
+
11
+
12
+ class ReplyError(LibvalkeyError):
13
+ ...
14
+
15
+
16
+ class Reader:
17
+ def __init__(
18
+ self,
19
+ protocolError: Callable[[str], Exception] = ...,
20
+ replyError: Callable[[str], Exception] = ...,
21
+ encoding: Optional[str] = ...,
22
+ errors: Optional[str] = ...,
23
+ notEnoughData: Any = ...,
24
+ convertSetsToLists: bool = ...,
25
+ ) -> None: ...
26
+
27
+ def feed(
28
+ self, __buf: Union[str, bytes], __off: int = ..., __len: int = ...
29
+ ) -> None: ...
30
+ def gets(self, __shouldDecode: bool = ...) -> Any: ...
31
+ def setmaxbuf(self, __maxbuf: Optional[int]) -> None: ...
32
+ def getmaxbuf(self) -> int: ...
33
+ def len(self) -> int: ...
34
+ def has_data(self) -> bool: ...
35
+
36
+ def set_encoding(
37
+ self, encoding: Optional[str] = ..., errors: Optional[str] = ...
38
+ ) -> None: ...
39
+
40
+
41
+ def pack_command(cmd: Tuple[str | int | float | bytes | memoryview]): ...
libvalkey/py.typed ADDED
File without changes
libvalkey/version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "4.0.1"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-2023, the maintainers of this library.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.1
2
+ Name: libvalkey
3
+ Version: 4.0.1
4
+ Summary: Python wrapper for libvalkey
5
+ Home-page: https://github.com/valkey-io/libvalkey-py
6
+ Author: libvalkey-py authors
7
+ Author-email: libvalkey-py@lists.valkey.io
8
+ License: MIT
9
+ Project-URL: Changes, https://github.com/valkey-io/libvalkey-py/releases
10
+ Project-URL: Issue tracker, https://github.com/valkey-io/libvalkey-py/issues
11
+ Keywords: Valkey
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Programming Language :: C
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Classifier: Topic :: Software Development
28
+ Requires-Python: >=3.8
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+
32
+ # libvalkey-py
33
+
34
+ [![Build Status](https://github.com/valkey-io/libvalkey-py/actions/workflows/integration.yaml/badge.svg)](https://github.com/valkey-io/libvalkey-py/actions/workflows/integration.yaml)
35
+ [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
36
+ [![pypi](https://badge.fury.io/py/libvalkey.svg)](https://pypi.org/project/libvalkey/)
37
+
38
+ Python extension that wraps protocol parsing code in [libvalkey][libvalkey].
39
+ It primarily speeds up parsing of multi bulk replies.
40
+
41
+ [libvalkey]: http://github.com/valkey-io/libvalkey
42
+
43
+ ## Install
44
+
45
+ libvalkey-py is available on [PyPI](https://pypi.org/project/libvalkey/), and can be installed via:
46
+
47
+ ```bash
48
+ pip install libvalkey
49
+ ```
50
+ ## Building and Testing
51
+
52
+ Building this repository requires a recursive checkout of submodules, and building libvalkey. The following example shows how to clone, compile, and run tests. Please note - you will need the gcc installed.
53
+
54
+ ```bash
55
+ git clone --recurse-submodules https://github.com/valkey-io/libvalkey-py
56
+ python setup.py build_ext --inplace
57
+ python -m pytest
58
+ ```
59
+
60
+ ### Requirements
61
+
62
+ libvalkey-py requires **Python 3.8+**.
63
+
64
+ Make sure Python development headers are available when installing libvalkey-py.
65
+ On Ubuntu/Debian systems, install them with `apt-get install python3-dev`.
66
+
67
+ ## Usage
68
+
69
+ The `libvalkey` module contains the `Reader` class. This class is responsible for
70
+ parsing replies from the stream of data that is read from a Redis connection.
71
+ It does not contain functionality to handle I/O.
72
+
73
+ ### Reply parser
74
+
75
+ The `Reader` class has two methods that are used when parsing replies from a
76
+ stream of data. `Reader.feed` takes a string argument that is appended to the
77
+ internal buffer. `Reader.gets` reads this buffer and returns a reply when the
78
+ buffer contains a full reply. If a single call to `feed` contains multiple
79
+ replies, `gets` should be called multiple times to extract all replies.
80
+
81
+ Example:
82
+
83
+ ```python
84
+ >>> reader = libvalkey.Reader()
85
+ >>> reader.feed("$5\r\nhello\r\n")
86
+ >>> reader.gets()
87
+ b'hello'
88
+ ```
89
+
90
+ When the buffer does not contain a full reply, `gets` returns `False`.
91
+ This means extra data is needed and `feed` should be called again before calling
92
+ `gets` again. Alternatively you could provide custom sentinel object via parameter,
93
+ which is useful for RESP3 protocol where native boolean types are supported:
94
+
95
+ Example:
96
+
97
+ ```python
98
+ >>> reader.feed("*2\r\n$5\r\nhello\r\n")
99
+ >>> reader.gets()
100
+ False
101
+ >>> reader.feed("$5\r\nworld\r\n")
102
+ >>> reader.gets()
103
+ [b'hello', b'world']
104
+ >>> reader = libvalkey.Reader(notEnoughData=Ellipsis)
105
+ >>> reader.gets()
106
+ Ellipsis
107
+ ```
108
+
109
+ #### Unicode
110
+
111
+ `libvalkey.Reader` is able to decode bulk data to any encoding Python supports.
112
+ To do so, specify the encoding you want to use for decoding replies when
113
+ initializing it:
114
+
115
+ ```python
116
+ >>> reader = libvalkey.Reader(encoding="utf-8", errors="strict")
117
+ >>> reader.feed(b"$3\r\n\xe2\x98\x83\r\n")
118
+ >>> reader.gets()
119
+ '☃'
120
+ ```
121
+
122
+ Decoding of bulk data will be attempted using the specified encoding and
123
+ error handler. If the error handler is `'strict'` (the default), a
124
+ `UnicodeDecodeError` is raised when data cannot be dedcoded. This is identical
125
+ to Python's default behavior. Other valid values to `errors` include
126
+ `'replace'`, `'ignore'`, and `'backslashreplace'`. More information on the
127
+ behavior of these error handlers can be found
128
+ [here](https://docs.python.org/3/howto/unicode.html#the-string-type).
129
+
130
+
131
+ When the specified encoding cannot be found, a `LookupError` will be raised
132
+ when calling `gets` for the first reply with bulk data.
133
+
134
+ #### Error handling
135
+
136
+ When a protocol error occurs (because of multiple threads using the same
137
+ socket, or some other condition that causes a corrupt stream), the error
138
+ `libvalkey.ProtocolError` is raised. Because the buffer is read in a lazy
139
+ fashion, it will only be raised when `gets` is called and the first reply in
140
+ the buffer contains an error. There is no way to recover from a faulty protocol
141
+ state, so when this happens, the I/O code feeding data to `Reader` should
142
+ probably reconnect.
143
+
144
+ The server can reply with error replies (`-ERR ...`). For these replies, the
145
+ custom error class `libvalkey.ReplyError` is returned, **but not raised**.
146
+
147
+ When other error types should be used (so existing code doesn't have to change
148
+ its `except` clauses), `Reader` can be initialized with the `protocolError` and
149
+ `replyError` keywords. These keywords should contain a *class* that is a
150
+ subclass of `Exception`. When not provided, `Reader` will use the default
151
+ error types.
152
+
153
+ ## Benchmarks
154
+
155
+ The repository contains a benchmarking script in the `benchmark` directory,
156
+ which uses [gevent](http://gevent.org/) to have non-blocking I/O and valkey-py
157
+ to handle connections. These benchmarks are done with a patched version of
158
+ valkey-py that uses libvalkey-py when it is available.
159
+
160
+ All benchmarks are done with 10 concurrent connections.
161
+
162
+ * SET key value + GET key
163
+ * valkey-py: 11.76 Kops
164
+ * valkey-py *with* libvalkey-py: 13.40 Kops
165
+ * improvement: **1.1x**
166
+
167
+ List entries in the following tests are 5 bytes.
168
+
169
+ * LRANGE list 0 **9**:
170
+ * valkey-py: 4.78 Kops
171
+ * valkey-py *with* libvalkey-py: 12.94 Kops
172
+ * improvement: **2.7x**
173
+ * LRANGE list 0 **99**:
174
+ * valkey-py: 0.73 Kops
175
+ * valkey-py *with* libvalkey-py: 11.90 Kops
176
+ * improvement: **16.3x**
177
+ * LRANGE list 0 **999**:
178
+ * valkey-py: 0.07 Kops
179
+ * valkey-py *with* libvalkey-py: 5.83 Kops
180
+ * improvement: **83.2x**
181
+
182
+ Throughput improvement for simple SET/GET is minimal, but the larger multi bulk replies
183
+ get, the larger the performance improvement is.
184
+
185
+ ## License
186
+
187
+ This code is released under the BSD license, as the license of hiredis-py at
188
+ the time of fork.
@@ -0,0 +1,10 @@
1
+ libvalkey/__init__.py,sha256=e0x4KLm03SiGOpd5pF8geg-GF7lJ-1YRYbjglbasTQY,263
2
+ libvalkey/libvalkey.cp313-win32.pyd,sha256=oDGqpPD_4u6xi_RF6q2PGs4w2KilKUngRn3-1JNSnXY,25600
3
+ libvalkey/libvalkey.pyi,sha256=QLLtneWQmvA3LRBBzxY6jLlKBhnJ6sFAxyJkEE-fgLI,1083
4
+ libvalkey/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ libvalkey/version.py,sha256=wuVMUjeHvq30g-AY0mmBNhxfw4LLIgHebrOJItvPySw,23
6
+ libvalkey-4.0.1.dist-info/LICENSE,sha256=conaokuK9E421nGlinNCluNeX0ZrBe9EdzxSpzOixu8,1116
7
+ libvalkey-4.0.1.dist-info/METADATA,sha256=B6fNmPrHGe1INLKwWFkFinJgOvXQ4PpLpKW2Ma4lWDg,7134
8
+ libvalkey-4.0.1.dist-info/WHEEL,sha256=pUXSsnGWJ09R6rv65E7mPoM8rWovBqrkySmEuK3ly_A,97
9
+ libvalkey-4.0.1.dist-info/top_level.txt,sha256=gi6FE63IEu45XD4W_yho-3AeC_gthFnEZVXDI9zburA,10
10
+ libvalkey-4.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win32
5
+
@@ -0,0 +1 @@
1
+ libvalkey