libvalkey 4.2.1__cp315-cp315-win_arm64.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,17 @@
1
+ from libvalkey.libvalkey import (
2
+ LibvalkeyError,
3
+ ProtocolError,
4
+ Reader,
5
+ ReplyError,
6
+ pack_command,
7
+ )
8
+ from libvalkey.version import __version__
9
+
10
+ __all__ = [
11
+ "Reader",
12
+ "LibvalkeyError",
13
+ "pack_command",
14
+ "ProtocolError",
15
+ "ReplyError",
16
+ "__version__",
17
+ ]
Binary file
@@ -0,0 +1,29 @@
1
+ from typing import Any, Callable, Optional, Tuple, Union
2
+
3
+ class LibvalkeyError(Exception): ...
4
+ class ProtocolError(LibvalkeyError): ...
5
+ class ReplyError(LibvalkeyError): ...
6
+
7
+ class Reader:
8
+ def __init__(
9
+ self,
10
+ protocolError: Callable[[str], Exception] = ...,
11
+ replyError: Callable[[str], Exception] = ...,
12
+ encoding: Optional[str] = ...,
13
+ errors: Optional[str] = ...,
14
+ notEnoughData: Any = ...,
15
+ convertSetsToLists: bool = ...,
16
+ ) -> None: ...
17
+ def feed(
18
+ self, __buf: Union[str, bytes], __off: int = ..., __len: int = ...
19
+ ) -> None: ...
20
+ def gets(self, __shouldDecode: bool = ...) -> Any: ...
21
+ def setmaxbuf(self, __maxbuf: Optional[int]) -> None: ...
22
+ def getmaxbuf(self) -> int: ...
23
+ def len(self) -> int: ...
24
+ def has_data(self) -> bool: ...
25
+ def set_encoding(
26
+ self, encoding: Optional[str] = ..., errors: Optional[str] = ...
27
+ ) -> None: ...
28
+
29
+ def pack_command(cmd: Tuple[str | int | float | bytes | memoryview, ...]) -> bytes: ...
libvalkey/py.typed ADDED
File without changes
libvalkey/version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "4.2.1"
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: libvalkey
3
+ Version: 4.2.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.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Classifier: Programming Language :: Python :: Implementation :: CPython
26
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
27
+ Classifier: Topic :: Software Development
28
+ Requires-Python: >=3.11
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Dynamic: author
32
+ Dynamic: author-email
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: description-content-type
36
+ Dynamic: home-page
37
+ Dynamic: keywords
38
+ Dynamic: license
39
+ Dynamic: license-file
40
+ Dynamic: project-url
41
+ Dynamic: requires-python
42
+ Dynamic: summary
43
+
44
+ # libvalkey-py
45
+
46
+ [![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)
47
+ [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
48
+ [![pypi](https://badge.fury.io/py/libvalkey.svg)](https://pypi.org/project/libvalkey/)
49
+
50
+ Python extension that wraps protocol parsing code in [libvalkey][libvalkey].
51
+ It primarily speeds up parsing of multi bulk replies.
52
+
53
+ [libvalkey]: http://github.com/valkey-io/libvalkey
54
+
55
+ ## Install
56
+
57
+ libvalkey-py is available on [PyPI](https://pypi.org/project/libvalkey/), and can be installed via:
58
+
59
+ ```bash
60
+ pip install libvalkey
61
+ ```
62
+ ## Building and Testing
63
+
64
+ 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.
65
+
66
+ ```bash
67
+ git clone --recurse-submodules https://github.com/valkey-io/libvalkey-py
68
+ python setup.py build_ext --inplace
69
+ python -m pytest
70
+ ```
71
+
72
+ ### Requirements
73
+
74
+ libvalkey-py requires **Python 3.11+**.
75
+
76
+ Make sure Python development headers are available when installing libvalkey-py.
77
+ On Ubuntu/Debian systems, install them with `apt-get install python3-dev`.
78
+
79
+ ## Usage
80
+
81
+ The `libvalkey` module contains the `Reader` class. This class is responsible for
82
+ parsing replies from the stream of data that is read from a Redis connection.
83
+ It does not contain functionality to handle I/O.
84
+
85
+ ### Reply parser
86
+
87
+ The `Reader` class has two methods that are used when parsing replies from a
88
+ stream of data. `Reader.feed` takes a string argument that is appended to the
89
+ internal buffer. `Reader.gets` reads this buffer and returns a reply when the
90
+ buffer contains a full reply. If a single call to `feed` contains multiple
91
+ replies, `gets` should be called multiple times to extract all replies.
92
+
93
+ Example:
94
+
95
+ ```python
96
+ >>> reader = libvalkey.Reader()
97
+ >>> reader.feed("$5\r\nhello\r\n")
98
+ >>> reader.gets()
99
+ b'hello'
100
+ ```
101
+
102
+ When the buffer does not contain a full reply, `gets` returns `False`.
103
+ This means extra data is needed and `feed` should be called again before calling
104
+ `gets` again. Alternatively you could provide custom sentinel object via parameter,
105
+ which is useful for RESP3 protocol where native boolean types are supported:
106
+
107
+ Example:
108
+
109
+ ```python
110
+ >>> reader.feed("*2\r\n$5\r\nhello\r\n")
111
+ >>> reader.gets()
112
+ False
113
+ >>> reader.feed("$5\r\nworld\r\n")
114
+ >>> reader.gets()
115
+ [b'hello', b'world']
116
+ >>> reader = libvalkey.Reader(notEnoughData=Ellipsis)
117
+ >>> reader.gets()
118
+ Ellipsis
119
+ ```
120
+
121
+ #### Unicode
122
+
123
+ `libvalkey.Reader` is able to decode bulk data to any encoding Python supports.
124
+ To do so, specify the encoding you want to use for decoding replies when
125
+ initializing it:
126
+
127
+ ```python
128
+ >>> reader = libvalkey.Reader(encoding="utf-8", errors="strict")
129
+ >>> reader.feed(b"$3\r\n\xe2\x98\x83\r\n")
130
+ >>> reader.gets()
131
+ '☃'
132
+ ```
133
+
134
+ Decoding of bulk data will be attempted using the specified encoding and
135
+ error handler. If the error handler is `'strict'` (the default), a
136
+ `UnicodeDecodeError` is raised when data cannot be decoded. This is identical
137
+ to Python's default behavior. Other valid values to `errors` include
138
+ `'replace'`, `'ignore'`, and `'backslashreplace'`. See [Unicode HOWTO: The String Type](https://docs.python.org/3/howto/unicode.html#the-string-type) for more information on the behavior of these error handlers.
139
+
140
+
141
+ When the specified encoding cannot be found, a `LookupError` will be raised
142
+ when calling `gets` for the first reply with bulk data.
143
+
144
+ #### Error handling
145
+
146
+ When a protocol error occurs (because of multiple threads using the same
147
+ socket, or some other condition that causes a corrupt stream), the error
148
+ `libvalkey.ProtocolError` is raised. Because the buffer is read in a lazy
149
+ fashion, it will only be raised when `gets` is called and the first reply in
150
+ the buffer contains an error. There is no way to recover from a faulty protocol
151
+ state, so when this happens, the I/O code feeding data to `Reader` should
152
+ probably reconnect.
153
+
154
+ The server can reply with error replies (`-ERR ...`). For these replies, the
155
+ custom error class `libvalkey.ReplyError` is returned, **but not raised**.
156
+
157
+ When other error types should be used (so existing code doesn't have to change
158
+ its `except` clauses), `Reader` can be initialized with the `protocolError` and
159
+ `replyError` keywords. These keywords should contain a *class* that is a
160
+ subclass of `Exception`. When not provided, `Reader` will use the default
161
+ error types.
162
+
163
+ ## Benchmarks
164
+
165
+ The repository contains a benchmarking script in the `benchmark` directory,
166
+ which uses [gevent](http://gevent.org/) to have non-blocking I/O and valkey-py
167
+ to handle connections. These benchmarks are done with a patched version of
168
+ valkey-py that uses libvalkey-py when it is available.
169
+
170
+ All benchmarks are done with 10 concurrent connections.
171
+
172
+ * SET key value + GET key
173
+ * valkey-py: 11.76 Kops
174
+ * valkey-py *with* libvalkey-py: 13.40 Kops
175
+ * improvement: **1.1x**
176
+
177
+ List entries in the following tests are 5 bytes.
178
+
179
+ * LRANGE list 0 **9**:
180
+ * valkey-py: 4.78 Kops
181
+ * valkey-py *with* libvalkey-py: 12.94 Kops
182
+ * improvement: **2.7x**
183
+ * LRANGE list 0 **99**:
184
+ * valkey-py: 0.73 Kops
185
+ * valkey-py *with* libvalkey-py: 11.90 Kops
186
+ * improvement: **16.3x**
187
+ * LRANGE list 0 **999**:
188
+ * valkey-py: 0.07 Kops
189
+ * valkey-py *with* libvalkey-py: 5.83 Kops
190
+ * improvement: **83.2x**
191
+
192
+ Throughput improvement for simple SET/GET is minimal, but the larger multi bulk replies
193
+ get, the larger the performance improvement is.
194
+
195
+ ## License
196
+
197
+ This code is released under the BSD license, as the license of hiredis-py at
198
+ the time of fork.
@@ -0,0 +1,10 @@
1
+ libvalkey/__init__.py,sha256=nJAGy-oJtpTAS8-VX1rPQJlvghJ32AzZk1yu2Nwx22I,309
2
+ libvalkey/libvalkey.cp315-win_arm64.pyd,sha256=sZDfPSfPhLi5mfc0V0K2F32YWdXoKOgOBp2vIQUA5YI,105984
3
+ libvalkey/libvalkey.pyi,sha256=KTMClZy2iF9lDdouivrDrJfSyVZ8IuewbJ99LMmQW8A,1064
4
+ libvalkey/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ libvalkey/version.py,sha256=OBHQsYnvsoIEuI_8rzauO94Eujv15H2u9XH2xsQ1AOs,23
6
+ libvalkey-4.2.1.dist-info/licenses/LICENSE,sha256=conaokuK9E421nGlinNCluNeX0ZrBe9EdzxSpzOixu8,1116
7
+ libvalkey-4.2.1.dist-info/METADATA,sha256=SHmUeGd1R3p_OvJenVeWcFqjoQ6L7wBAnhdzTUVk3Xk,7438
8
+ libvalkey-4.2.1.dist-info/WHEEL,sha256=g1f1kqn4IVvU4p3uh1e39gJzHxbtC9umA5gNjEXIByA,101
9
+ libvalkey-4.2.1.dist-info/top_level.txt,sha256=gi6FE63IEu45XD4W_yho-3AeC_gthFnEZVXDI9zburA,10
10
+ libvalkey-4.2.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp315-cp315-win_arm64
5
+
@@ -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 @@
1
+ libvalkey