1
- def gxhash32 (input_bytes : bytes , seed : int ) -> int :
1
+ from typing import Protocol
2
+
3
+ class File (Protocol ):
4
+ def fileno (self ) -> int : ...
5
+
6
+ def gxhash32 (file : File , seed : int ) -> int :
2
7
"""
3
8
Summary
4
9
-------
@@ -7,28 +12,31 @@ def gxhash32(input_bytes: bytes, seed: int) -> int:
7
12
8
13
Parameters
9
14
----------
10
- input_bytes (bytes): input bytes to hash
15
+ file (File)
16
+ file-like object
11
17
12
- seed (int): seed for the hash function
18
+ seed (int)
19
+ seed for the hash function
13
20
14
21
15
22
Returns
16
23
-------
17
- hash (int): u32 hash of the input bytes
24
+ hash (int)
25
+ u32 hash of the input bytes
18
26
19
27
20
28
Example
21
29
-------
22
30
```python
23
- import gxhash
24
-
25
- input_bytes = bytes([42] * 1000 )
31
+ file = TemporaryFile()
32
+ file.write(bytes([42] * 1000))
33
+ file.seek(0 )
26
34
seed = 1234
27
- print(f"Hash is {gxhash.gxhash32(input_bytes , seed)}!")
35
+ print(f"Hash is {gxhash.gxhash32(file , seed)}!")
28
36
```
29
37
"""
30
38
31
- def gxhash32_nogil ( input_bytes : bytes , seed : int ) -> int :
39
+ async def gxhash32_async ( file : File , seed : int ) -> int :
32
40
"""
33
41
Summary
34
42
-------
@@ -37,28 +45,31 @@ def gxhash32_nogil(input_bytes: bytes, seed: int) -> int:
37
45
38
46
Parameters
39
47
----------
40
- input_bytes (bytes): input bytes to hash
48
+ file (File)
49
+ file-like object
41
50
42
- seed (int): seed for the hash function
51
+ seed (int)
52
+ seed for the hash function
43
53
44
54
45
55
Returns
46
56
-------
47
- hash (int): u32 hash of the input bytes
57
+ hash (Awaitable[int])
58
+ u32 hash of the input bytes
48
59
49
60
50
61
Example
51
62
-------
52
63
```python
53
- import gxhash
54
-
55
- input_bytes = bytes([42] * 1000 )
64
+ file = TemporaryFile()
65
+ file.write(bytes([42] * 1000))
66
+ file.seek(0 )
56
67
seed = 1234
57
- print(f"Hash is {gxhash.gxhash32_nogil(input_bytes , seed)}!")
68
+ print(f"Hash is {gxhash.gxhash32_async(file , seed)}!")
58
69
```
59
70
"""
60
71
61
- def gxhash64 (input_bytes : bytes , seed : int ) -> int :
72
+ def gxhash64 (file : File , seed : int ) -> int :
62
73
"""
63
74
Summary
64
75
-------
@@ -67,28 +78,31 @@ def gxhash64(input_bytes: bytes, seed: int) -> int:
67
78
68
79
Parameters
69
80
----------
70
- input_bytes (bytes): input bytes to hash
81
+ file (File)
82
+ file-like object
71
83
72
- seed (int): seed for the hash function
84
+ seed (int)
85
+ seed for the hash function
73
86
74
87
75
88
Returns
76
89
-------
77
- hash (int): u64 hash of the input bytes
90
+ hash (int)
91
+ u64 hash of the input bytes
78
92
79
93
80
94
Example
81
95
-------
82
96
```python
83
- import gxhash
84
-
85
- input_bytes = bytes([42] * 1000 )
97
+ file = TemporaryFile()
98
+ file.write(bytes([42] * 1000))
99
+ file.seek(0 )
86
100
seed = 1234
87
- print(f"Hash is {gxhash.gxhash64(input_bytes , seed)}!")
101
+ print(f"Hash is {gxhash.gxhash64(file , seed)}!")
88
102
```
89
103
"""
90
104
91
- def gxhash64_nogil ( input_bytes : bytes , seed : int ) -> int :
105
+ async def gxhash64_async ( file : File , seed : int ) -> int :
92
106
"""
93
107
Summary
94
108
-------
@@ -97,28 +111,31 @@ def gxhash64_nogil(input_bytes: bytes, seed: int) -> int:
97
111
98
112
Parameters
99
113
----------
100
- input_bytes (bytes): input bytes to hash
114
+ file (File)
115
+ file-like object
101
116
102
- seed (int): seed for the hash function
117
+ seed (int)
118
+ seed for the hash function
103
119
104
120
105
121
Returns
106
122
-------
107
- hash (int): u64 hash of the input bytes
123
+ hash (Awaitable[int])
124
+ u64 hash of the input bytes
108
125
109
126
110
127
Example
111
128
-------
112
129
```python
113
- import gxhash
114
-
115
- input_bytes = bytes([42] * 1000 )
130
+ file = TemporaryFile()
131
+ file.write(bytes([42] * 1000))
132
+ file.seek(0 )
116
133
seed = 1234
117
- print(f"Hash is {gxhash.gxhash64_nogil(input_bytes , seed)}!")
134
+ print(f"Hash is {gxhash.gxhash64_async(file , seed)}!")
118
135
```
119
136
"""
120
137
121
- def gxhash128 (input_bytes : bytes , seed : int ) -> int :
138
+ def gxhash128 (file : File , seed : int ) -> int :
122
139
"""
123
140
Summary
124
141
-------
@@ -127,28 +144,31 @@ def gxhash128(input_bytes: bytes, seed: int) -> int:
127
144
128
145
Parameters
129
146
----------
130
- input_bytes (bytes): input bytes to hash
147
+ file (File)
148
+ file-like object
131
149
132
- seed (int): seed for the hash function
150
+ seed (int)
151
+ seed for the hash function
133
152
134
153
135
154
Returns
136
155
-------
137
- hash (int): u128 hash of the input bytes
156
+ hash (int)
157
+ u128 hash of the input bytes
138
158
139
159
140
160
Example
141
161
-------
142
162
```python
143
- import gxhash
144
-
145
- input_bytes = bytes([42] * 1000 )
163
+ file = TemporaryFile()
164
+ file.write(bytes([42] * 1000))
165
+ file.seek(0 )
146
166
seed = 1234
147
- print(f"Hash is {gxhash.gxhash128(input_bytes , seed)}!")
167
+ print(f"Hash is {gxhash.gxhash128(file , seed)}!")
148
168
```
149
169
"""
150
170
151
- def gxhash128_nogil ( input_bytes : bytes , seed : int ) -> int :
171
+ async def gxhash128_async ( file : File , seed : int ) -> int :
152
172
"""
153
173
Summary
154
174
-------
@@ -157,23 +177,26 @@ def gxhash128_nogil(input_bytes: bytes, seed: int) -> int:
157
177
158
178
Parameters
159
179
----------
160
- input_bytes (bytes): input bytes to hash
180
+ file (File)
181
+ file-like object
161
182
162
- seed (int): seed for the hash function
183
+ seed (int)
184
+ seed for the hash function
163
185
164
186
165
187
Returns
166
188
-------
167
- hash (int): u128 hash of the input bytes
189
+ hash (Awaitable[int])
190
+ u128 hash of the input bytes
168
191
169
192
170
193
Example
171
194
-------
172
195
```python
173
- import gxhash
174
-
175
- input_bytes = bytes([42] * 1000 )
196
+ file = TemporaryFile()
197
+ file.write(bytes([42] * 1000))
198
+ file.seek(0 )
176
199
seed = 1234
177
- print(f"Hash is {gxhash.gxhash128_nogil(input_bytes , seed)}!")
200
+ print(f"Hash is {gxhash.gxhash128_async(file , seed)}!")
178
201
```
179
202
"""
0 commit comments