Skip to content

Commit 05b3ccc

Browse files
authored
Sync mypy including the stubs (#14)
1 parent abf92aa commit 05b3ccc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+7194
-8
lines changed

.github/workflows/buildwheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Copy library content
9191
shell: bash
9292
run: |
93-
cp lib-rt/* .
93+
cp -r lib-rt/* .
9494
9595
- uses: pypa/cibuildwheel@v3.2.0
9696
with:
@@ -117,7 +117,7 @@ jobs:
117117
python-version: "3.9"
118118
- name: Build sdist
119119
run: |
120-
cp lib-rt/* .
120+
cp -r lib-rt/* .
121121
pip install --upgrade setuptools build
122122
python -m build --sdist
123123
- uses: actions/upload-artifact@v4

LICENSE

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,38 @@ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
226226
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
227227
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
228228
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
229+
230+
= = = = =
231+
232+
Files under lib-rt/base64 are licensed under the following license.
233+
234+
= = = = =
235+
236+
Copyright (c) 2005-2007, Nick Galbreath
237+
Copyright (c) 2015-2018, Wojciech Muła
238+
Copyright (c) 2016-2017, Matthieu Darbois
239+
Copyright (c) 2013-2022, Alfred Klomp
240+
All rights reserved.
241+
242+
Redistribution and use in source and binary forms, with or without
243+
modification, are permitted provided that the following conditions are
244+
met:
245+
246+
- Redistributions of source code must retain the above copyright notice,
247+
this list of conditions and the following disclaimer.
248+
249+
- Redistributions in binary form must reproduce the above copyright
250+
notice, this list of conditions and the following disclaimer in the
251+
documentation and/or other materials provided with the distribution.
252+
253+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
254+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
255+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
256+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
257+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
258+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
259+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
260+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
261+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
262+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
263+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

lib-rt/CPy.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ PyObject *CPy_Encode(PyObject *obj, PyObject *encoding, PyObject *errors);
770770
Py_ssize_t CPyStr_Count(PyObject *unicode, PyObject *substring, CPyTagged start);
771771
Py_ssize_t CPyStr_CountFull(PyObject *unicode, PyObject *substring, CPyTagged start, CPyTagged end);
772772
CPyTagged CPyStr_Ord(PyObject *obj);
773+
PyObject *CPyStr_Multiply(PyObject *str, CPyTagged count);
773774

774775

775776
// Bytes operations
@@ -781,6 +782,8 @@ CPyTagged CPyBytes_GetItem(PyObject *o, CPyTagged index);
781782
PyObject *CPyBytes_Concat(PyObject *a, PyObject *b);
782783
PyObject *CPyBytes_Join(PyObject *sep, PyObject *iter);
783784
CPyTagged CPyBytes_Ord(PyObject *obj);
785+
PyObject *CPyBytes_Multiply(PyObject *bytes, CPyTagged count);
786+
PyObject *CPyBytes_Translate(PyObject *bytes, PyObject *table);
784787

785788

786789
int CPyBytes_Compare(PyObject *left, PyObject *right);
@@ -958,6 +961,26 @@ static inline int CPyObject_GenericSetAttr(PyObject *self, PyObject *name, PyObj
958961
return _PyObject_GenericSetAttrWithDict(self, name, value, NULL);
959962
}
960963

964+
PyObject *CPy_SetupObject(PyObject *type);
965+
966+
typedef struct {
967+
PyCMethodObject func;
968+
969+
PyObject *func_name;
970+
PyObject *func_code;
971+
} CPyFunction;
972+
973+
PyObject* CPyFunction_New(PyObject *module, const char *filename, const char *funcname,
974+
PyCFunction func, int func_flags, const char *func_doc,
975+
int first_line, int code_flags);
976+
PyObject* CPyFunction_get_name(PyObject *op, void *context);
977+
int CPyFunction_set_name(PyObject *op, PyObject *value, void *context);
978+
PyObject* CPyFunction_get_code(PyObject *op, void *context);
979+
PyObject* CPyFunction_get_defaults(PyObject *op, void *context);
980+
PyObject* CPyFunction_get_kwdefaults(PyObject *op, void *context);
981+
PyObject* CPyFunction_get_annotations(PyObject *op, void *context);
982+
int CPyFunction_set_annotations(PyObject *op, PyObject *value, void *context);
983+
961984
#if CPY_3_11_FEATURES
962985
PyObject *CPy_GetName(PyObject *obj);
963986
#endif

lib-rt/base64/arch/avx/codec.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <stdint.h>
2+
#include <stddef.h>
3+
#include <stdlib.h>
4+
5+
#include "libbase64.h"
6+
#include "../../tables/tables.h"
7+
#include "../../codecs.h"
8+
#include "config.h"
9+
#include "../../env.h"
10+
11+
#if HAVE_AVX
12+
#include <immintrin.h>
13+
14+
// Only enable inline assembly on supported compilers and on 64-bit CPUs.
15+
#ifndef BASE64_AVX_USE_ASM
16+
# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
17+
# define BASE64_AVX_USE_ASM 1
18+
# else
19+
# define BASE64_AVX_USE_ASM 0
20+
# endif
21+
#endif
22+
23+
#include "../ssse3/dec_reshuffle.c"
24+
#include "../ssse3/dec_loop.c"
25+
26+
#if BASE64_AVX_USE_ASM
27+
# include "./enc_loop_asm.c"
28+
#else
29+
# include "../ssse3/enc_translate.c"
30+
# include "../ssse3/enc_reshuffle.c"
31+
# include "../ssse3/enc_loop.c"
32+
#endif
33+
34+
#endif // HAVE_AVX
35+
36+
void
37+
base64_stream_encode_avx BASE64_ENC_PARAMS
38+
{
39+
#if HAVE_AVX
40+
#include "../generic/enc_head.c"
41+
42+
// For supported compilers, use a hand-optimized inline assembly
43+
// encoder. Otherwise fall back on the SSSE3 encoder, but compiled with
44+
// AVX flags to generate better optimized AVX code.
45+
46+
#if BASE64_AVX_USE_ASM
47+
enc_loop_avx(&s, &slen, &o, &olen);
48+
#else
49+
enc_loop_ssse3(&s, &slen, &o, &olen);
50+
#endif
51+
52+
#include "../generic/enc_tail.c"
53+
#else
54+
base64_enc_stub(state, src, srclen, out, outlen);
55+
#endif
56+
}
57+
58+
int
59+
base64_stream_decode_avx BASE64_DEC_PARAMS
60+
{
61+
#if HAVE_AVX
62+
#include "../generic/dec_head.c"
63+
dec_loop_ssse3(&s, &slen, &o, &olen);
64+
#include "../generic/dec_tail.c"
65+
#else
66+
return base64_dec_stub(state, src, srclen, out, outlen);
67+
#endif
68+
}

0 commit comments

Comments
 (0)