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