passagemath-objects 10.6.42__cp314-cp314-musllinux_1_2_x86_64.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.
Potentially problematic release.
This version of passagemath-objects might be problematic. Click here for more details.
- passagemath_objects/__init__.py +3 -0
- passagemath_objects-10.6.42.dist-info/METADATA +115 -0
- passagemath_objects-10.6.42.dist-info/RECORD +280 -0
- passagemath_objects-10.6.42.dist-info/WHEEL +5 -0
- passagemath_objects-10.6.42.dist-info/top_level.txt +3 -0
- passagemath_objects.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- sage/all__sagemath_objects.py +37 -0
- sage/arith/all__sagemath_objects.py +5 -0
- sage/arith/long.pxd +411 -0
- sage/arith/numerical_approx.cpython-314-x86_64-linux-musl.so +0 -0
- sage/arith/numerical_approx.pxd +35 -0
- sage/arith/numerical_approx.pyx +75 -0
- sage/arith/power.cpython-314-x86_64-linux-musl.so +0 -0
- sage/arith/power.pxd +31 -0
- sage/arith/power.pyx +127 -0
- sage/categories/action.cpython-314-x86_64-linux-musl.so +0 -0
- sage/categories/action.pxd +29 -0
- sage/categories/action.pyx +641 -0
- sage/categories/algebra_functor.py +745 -0
- sage/categories/all__sagemath_objects.py +33 -0
- sage/categories/basic.py +62 -0
- sage/categories/cartesian_product.py +295 -0
- sage/categories/category.py +3401 -0
- sage/categories/category_cy_helper.cpython-314-x86_64-linux-musl.so +0 -0
- sage/categories/category_cy_helper.pxd +8 -0
- sage/categories/category_cy_helper.pyx +322 -0
- sage/categories/category_singleton.cpython-314-x86_64-linux-musl.so +0 -0
- sage/categories/category_singleton.pxd +3 -0
- sage/categories/category_singleton.pyx +342 -0
- sage/categories/category_types.py +637 -0
- sage/categories/category_with_axiom.py +2876 -0
- sage/categories/covariant_functorial_construction.py +703 -0
- sage/categories/facade_sets.py +228 -0
- sage/categories/functor.cpython-314-x86_64-linux-musl.so +0 -0
- sage/categories/functor.pxd +7 -0
- sage/categories/functor.pyx +691 -0
- sage/categories/homset.py +1338 -0
- sage/categories/homsets.py +364 -0
- sage/categories/isomorphic_objects.py +73 -0
- sage/categories/map.cpython-314-x86_64-linux-musl.so +0 -0
- sage/categories/map.pxd +34 -0
- sage/categories/map.pyx +2112 -0
- sage/categories/morphism.cpython-314-x86_64-linux-musl.so +0 -0
- sage/categories/morphism.pxd +14 -0
- sage/categories/morphism.pyx +895 -0
- sage/categories/objects.py +167 -0
- sage/categories/primer.py +1696 -0
- sage/categories/pushout.py +4834 -0
- sage/categories/quotients.py +64 -0
- sage/categories/realizations.py +200 -0
- sage/categories/sets_cat.py +3228 -0
- sage/categories/sets_with_partial_maps.py +52 -0
- sage/categories/subobjects.py +64 -0
- sage/categories/subquotients.py +21 -0
- sage/categories/with_realizations.py +311 -0
- sage/cpython/__init__.py +19 -0
- sage/cpython/_py2_random.py +619 -0
- sage/cpython/all.py +3 -0
- sage/cpython/atexit.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/atexit.pyx +269 -0
- sage/cpython/builtin_types.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/builtin_types.pyx +7 -0
- sage/cpython/cython_metaclass.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/cython_metaclass.h +117 -0
- sage/cpython/cython_metaclass.pxd +3 -0
- sage/cpython/cython_metaclass.pyx +130 -0
- sage/cpython/debug.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/debug.pyx +302 -0
- sage/cpython/dict_del_by_value.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/dict_del_by_value.pxd +9 -0
- sage/cpython/dict_del_by_value.pyx +191 -0
- sage/cpython/dict_internal.h +245 -0
- sage/cpython/getattr.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/getattr.pxd +9 -0
- sage/cpython/getattr.pyx +439 -0
- sage/cpython/pycore_long.h +97 -0
- sage/cpython/pycore_long.pxd +10 -0
- sage/cpython/python_debug.h +44 -0
- sage/cpython/python_debug.pxd +47 -0
- sage/cpython/pyx_visit.h +13 -0
- sage/cpython/string.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/string.pxd +76 -0
- sage/cpython/string.pyx +34 -0
- sage/cpython/string_impl.h +60 -0
- sage/cpython/type.cpython-314-x86_64-linux-musl.so +0 -0
- sage/cpython/type.pxd +2 -0
- sage/cpython/type.pyx +40 -0
- sage/cpython/wrapperdescr.pxd +67 -0
- sage/ext/all__sagemath_objects.py +3 -0
- sage/ext/ccobject.h +64 -0
- sage/ext/cplusplus.pxd +17 -0
- sage/ext/mod_int.h +30 -0
- sage/ext/mod_int.pxd +24 -0
- sage/ext/stdsage.pxd +39 -0
- sage/groups/all__sagemath_objects.py +1 -0
- sage/groups/group.cpython-314-x86_64-linux-musl.so +0 -0
- sage/groups/group.pxd +14 -0
- sage/groups/group.pyx +322 -0
- sage/groups/old.cpython-314-x86_64-linux-musl.so +0 -0
- sage/groups/old.pxd +14 -0
- sage/groups/old.pyx +219 -0
- sage/libs/all__sagemath_objects.py +3 -0
- sage/libs/gmp/__init__.py +1 -0
- sage/libs/gmp/all.pxd +6 -0
- sage/libs/gmp/binop.pxd +23 -0
- sage/libs/gmp/misc.pxd +8 -0
- sage/libs/gmp/mpf.pxd +88 -0
- sage/libs/gmp/mpn.pxd +57 -0
- sage/libs/gmp/mpq.pxd +57 -0
- sage/libs/gmp/mpz.pxd +202 -0
- sage/libs/gmp/pylong.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/gmp/pylong.pxd +12 -0
- sage/libs/gmp/pylong.pyx +150 -0
- sage/libs/gmp/random.pxd +25 -0
- sage/libs/gmp/randomize.pxd +59 -0
- sage/libs/gmp/types.pxd +53 -0
- sage/libs/gmpxx.pxd +19 -0
- sage/misc/abstract_method.py +276 -0
- sage/misc/all__sagemath_objects.py +43 -0
- sage/misc/bindable_class.py +253 -0
- sage/misc/c3_controlled.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/c3_controlled.pxd +2 -0
- sage/misc/c3_controlled.pyx +1402 -0
- sage/misc/cachefunc.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/cachefunc.pxd +43 -0
- sage/misc/cachefunc.pyx +3781 -0
- sage/misc/call.py +188 -0
- sage/misc/classcall_metaclass.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/classcall_metaclass.pxd +14 -0
- sage/misc/classcall_metaclass.pyx +599 -0
- sage/misc/constant_function.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/constant_function.pyx +130 -0
- sage/misc/decorators.py +747 -0
- sage/misc/fast_methods.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/fast_methods.pxd +20 -0
- sage/misc/fast_methods.pyx +351 -0
- sage/misc/flatten.py +90 -0
- sage/misc/fpickle.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/fpickle.pyx +177 -0
- sage/misc/function_mangling.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/function_mangling.pxd +11 -0
- sage/misc/function_mangling.pyx +308 -0
- sage/misc/inherit_comparison.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/inherit_comparison.pxd +5 -0
- sage/misc/inherit_comparison.pyx +105 -0
- sage/misc/instancedoc.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/instancedoc.pyx +331 -0
- sage/misc/lazy_attribute.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_attribute.pyx +607 -0
- sage/misc/lazy_format.py +135 -0
- sage/misc/lazy_import.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_import.pyx +1299 -0
- sage/misc/lazy_import_cache.py +36 -0
- sage/misc/lazy_list.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_list.pxd +19 -0
- sage/misc/lazy_list.pyx +1187 -0
- sage/misc/lazy_string.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/lazy_string.pxd +7 -0
- sage/misc/lazy_string.pyx +546 -0
- sage/misc/misc.py +1066 -0
- sage/misc/misc_c.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/misc_c.pxd +3 -0
- sage/misc/misc_c.pyx +766 -0
- sage/misc/namespace_package.py +37 -0
- sage/misc/nested_class.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/nested_class.pxd +3 -0
- sage/misc/nested_class.pyx +394 -0
- sage/misc/persist.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/persist.pyx +1251 -0
- sage/misc/prandom.py +418 -0
- sage/misc/randstate.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/randstate.pxd +30 -0
- sage/misc/randstate.pyx +1059 -0
- sage/misc/repr.py +203 -0
- sage/misc/reset.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/reset.pyx +196 -0
- sage/misc/sage_ostools.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/sage_ostools.pyx +323 -0
- sage/misc/sage_timeit.py +275 -0
- sage/misc/sage_timeit_class.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/sage_timeit_class.pyx +120 -0
- sage/misc/sage_unittest.py +637 -0
- sage/misc/sageinspect.py +2768 -0
- sage/misc/session.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/session.pyx +392 -0
- sage/misc/superseded.py +557 -0
- sage/misc/test_nested_class.py +228 -0
- sage/misc/timing.py +264 -0
- sage/misc/unknown.py +222 -0
- sage/misc/verbose.py +253 -0
- sage/misc/weak_dict.cpython-314-x86_64-linux-musl.so +0 -0
- sage/misc/weak_dict.pxd +15 -0
- sage/misc/weak_dict.pyx +1231 -0
- sage/modules/all__sagemath_objects.py +1 -0
- sage/modules/module.cpython-314-x86_64-linux-musl.so +0 -0
- sage/modules/module.pxd +5 -0
- sage/modules/module.pyx +329 -0
- sage/rings/all__sagemath_objects.py +3 -0
- sage/rings/integer_fake.h +22 -0
- sage/rings/integer_fake.pxd +55 -0
- sage/sets/all__sagemath_objects.py +3 -0
- sage/sets/pythonclass.cpython-314-x86_64-linux-musl.so +0 -0
- sage/sets/pythonclass.pxd +9 -0
- sage/sets/pythonclass.pyx +247 -0
- sage/structure/__init__.py +4 -0
- sage/structure/all.py +30 -0
- sage/structure/category_object.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/category_object.pxd +28 -0
- sage/structure/category_object.pyx +1087 -0
- sage/structure/coerce.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/coerce.pxd +44 -0
- sage/structure/coerce.pyx +2107 -0
- sage/structure/coerce_actions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/coerce_actions.pxd +27 -0
- sage/structure/coerce_actions.pyx +988 -0
- sage/structure/coerce_dict.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/coerce_dict.pxd +51 -0
- sage/structure/coerce_dict.pyx +1557 -0
- sage/structure/coerce_exceptions.py +23 -0
- sage/structure/coerce_maps.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/coerce_maps.pxd +28 -0
- sage/structure/coerce_maps.pyx +718 -0
- sage/structure/debug_options.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/debug_options.pxd +6 -0
- sage/structure/debug_options.pyx +54 -0
- sage/structure/dynamic_class.py +541 -0
- sage/structure/element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/element.pxd +272 -0
- sage/structure/element.pyx +4772 -0
- sage/structure/element_wrapper.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/element_wrapper.pxd +12 -0
- sage/structure/element_wrapper.pyx +582 -0
- sage/structure/factorization.py +1422 -0
- sage/structure/factorization_integer.py +105 -0
- sage/structure/factory.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/factory.pyx +786 -0
- sage/structure/formal_sum.py +489 -0
- sage/structure/gens_py.py +73 -0
- sage/structure/global_options.py +1743 -0
- sage/structure/indexed_generators.py +863 -0
- sage/structure/list_clone.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/list_clone.pxd +65 -0
- sage/structure/list_clone.pyx +1867 -0
- sage/structure/list_clone_demo.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/list_clone_demo.pyx +248 -0
- sage/structure/list_clone_timings.py +179 -0
- sage/structure/list_clone_timings_cy.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/list_clone_timings_cy.pyx +86 -0
- sage/structure/mutability.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/mutability.pxd +21 -0
- sage/structure/mutability.pyx +348 -0
- sage/structure/nonexact.py +69 -0
- sage/structure/parent.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/parent.pxd +112 -0
- sage/structure/parent.pyx +3093 -0
- sage/structure/parent_base.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/parent_base.pxd +13 -0
- sage/structure/parent_base.pyx +44 -0
- sage/structure/parent_gens.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/parent_gens.pxd +22 -0
- sage/structure/parent_gens.pyx +377 -0
- sage/structure/parent_old.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/parent_old.pxd +25 -0
- sage/structure/parent_old.pyx +294 -0
- sage/structure/proof/__init__.py +1 -0
- sage/structure/proof/all.py +243 -0
- sage/structure/proof/proof.py +300 -0
- sage/structure/richcmp.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/richcmp.pxd +213 -0
- sage/structure/richcmp.pyx +495 -0
- sage/structure/sage_object.cpython-314-x86_64-linux-musl.so +0 -0
- sage/structure/sage_object.pxd +3 -0
- sage/structure/sage_object.pyx +988 -0
- sage/structure/sage_object_test.py +19 -0
- sage/structure/sequence.py +937 -0
- sage/structure/set_factories.py +1178 -0
- sage/structure/set_factories_example.py +527 -0
- sage/structure/support_view.py +179 -0
- sage/structure/test_factory.py +56 -0
- sage/structure/unique_representation.py +1359 -0
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
cdef extern from "Python.h":
|
|
3
|
+
cdef size_t SIZEOF_VOID_P
|
|
4
|
+
|
|
5
|
+
cdef class FastHashable_class:
|
|
6
|
+
cdef Py_ssize_t _hash
|
|
7
|
+
|
|
8
|
+
cdef inline long hash_by_id(void * p) noexcept:
|
|
9
|
+
r"""
|
|
10
|
+
This function is a copy paste from the default Python hash function.
|
|
11
|
+
"""
|
|
12
|
+
cdef long x
|
|
13
|
+
cdef size_t y = <size_t>p
|
|
14
|
+
# bottom 3 or 4 bits are likely to be 0; rotate y by 4 to avoid
|
|
15
|
+
# excessive hash collisions for dicts and sets
|
|
16
|
+
y = (y >> 4) | (y << (8 * SIZEOF_VOID_P - 4))
|
|
17
|
+
x = <long>y
|
|
18
|
+
if x == -1:
|
|
19
|
+
x = -2
|
|
20
|
+
return x
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"""
|
|
3
|
+
Fast methods via Cython
|
|
4
|
+
|
|
5
|
+
This module provides extension classes with useful methods of cython speed,
|
|
6
|
+
that python classes can inherit.
|
|
7
|
+
|
|
8
|
+
.. NOTE::
|
|
9
|
+
|
|
10
|
+
This module provides a cython base class :class:`WithEqualityById`
|
|
11
|
+
implementing unique instance behaviour, and a cython base class
|
|
12
|
+
:class:`FastHashable_class`, which has a quite fast hash
|
|
13
|
+
whose value can be freely chosen at initialisation time.
|
|
14
|
+
|
|
15
|
+
AUTHOR:
|
|
16
|
+
|
|
17
|
+
- Simon King (2013-02): Original version
|
|
18
|
+
- Simon King (2013-10): Add :class:`Singleton`
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
# ****************************************************************************
|
|
22
|
+
# Copyright (C) 2013 Simon A. King <simon.king at uni-jena.de>
|
|
23
|
+
#
|
|
24
|
+
# This program is free software: you can redistribute it and/or modify
|
|
25
|
+
# it under the terms of the GNU General Public License as published by
|
|
26
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
27
|
+
# (at your option) any later version.
|
|
28
|
+
# https://www.gnu.org/licenses/
|
|
29
|
+
# ****************************************************************************
|
|
30
|
+
|
|
31
|
+
from sage.misc.classcall_metaclass import ClasscallMetaclass, typecall
|
|
32
|
+
from sage.misc.constant_function import ConstantFunction
|
|
33
|
+
|
|
34
|
+
from cpython.object cimport Py_EQ, Py_NE
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
cdef class WithEqualityById:
|
|
38
|
+
"""
|
|
39
|
+
Provide hash and equality test based on identity.
|
|
40
|
+
|
|
41
|
+
.. NOTE::
|
|
42
|
+
|
|
43
|
+
This class provides the unique representation behaviour of
|
|
44
|
+
:class:`~sage.structure.unique_representation.UniqueRepresentation`,
|
|
45
|
+
together with :class:`~sage.structure.unique_representation.CachedRepresentation`.
|
|
46
|
+
|
|
47
|
+
EXAMPLES:
|
|
48
|
+
|
|
49
|
+
Any instance of :class:`~sage.structure.unique_representation.UniqueRepresentation`
|
|
50
|
+
inherits from :class:`WithEqualityById`.
|
|
51
|
+
::
|
|
52
|
+
|
|
53
|
+
sage: class MyParent(Parent):
|
|
54
|
+
....: def __init__(self, x):
|
|
55
|
+
....: self.x = x
|
|
56
|
+
....: def __hash__(self):
|
|
57
|
+
....: return hash(self.x)
|
|
58
|
+
sage: class MyUniqueParent(UniqueRepresentation, MyParent): pass
|
|
59
|
+
sage: issubclass(MyUniqueParent, sage.misc.fast_methods.WithEqualityById)
|
|
60
|
+
True
|
|
61
|
+
|
|
62
|
+
Inheriting from :class:`WithEqualityById` provides unique representation
|
|
63
|
+
behaviour::
|
|
64
|
+
|
|
65
|
+
sage: a = MyUniqueParent(1)
|
|
66
|
+
sage: b = MyUniqueParent(2)
|
|
67
|
+
sage: c = MyUniqueParent(1)
|
|
68
|
+
sage: a is c
|
|
69
|
+
True
|
|
70
|
+
sage: d = MyUniqueParent(-1)
|
|
71
|
+
sage: a == d
|
|
72
|
+
False
|
|
73
|
+
|
|
74
|
+
The hash inherited from ``MyParent`` is replaced by a hash that coincides
|
|
75
|
+
with :class:`object`'s hash::
|
|
76
|
+
|
|
77
|
+
sage: hash(a) == hash(a.x)
|
|
78
|
+
False
|
|
79
|
+
sage: hash(a) == object.__hash__(a)
|
|
80
|
+
True
|
|
81
|
+
|
|
82
|
+
.. WARNING::
|
|
83
|
+
|
|
84
|
+
It is possible to inherit from
|
|
85
|
+
:class:`~sage.structure.unique_representation.UniqueRepresentation`
|
|
86
|
+
and then overload equality test in a way that destroys the unique
|
|
87
|
+
representation property. We strongly recommend against it! You should
|
|
88
|
+
use :class:`~sage.structure.unique_representation.CachedRepresentation`
|
|
89
|
+
instead.
|
|
90
|
+
|
|
91
|
+
::
|
|
92
|
+
|
|
93
|
+
sage: class MyNonUniqueParent(MyUniqueParent):
|
|
94
|
+
....: def __eq__(self, other):
|
|
95
|
+
....: return self.x^2 == other.x^2
|
|
96
|
+
sage: a = MyNonUniqueParent(1)
|
|
97
|
+
sage: d = MyNonUniqueParent(-1)
|
|
98
|
+
sage: a is MyNonUniqueParent(1)
|
|
99
|
+
True
|
|
100
|
+
sage: a == d
|
|
101
|
+
True
|
|
102
|
+
sage: a is d
|
|
103
|
+
False
|
|
104
|
+
"""
|
|
105
|
+
def __hash__(self):
|
|
106
|
+
"""
|
|
107
|
+
The hash provided by this class coincides with that of ``<class 'object'>``.
|
|
108
|
+
|
|
109
|
+
TESTS::
|
|
110
|
+
|
|
111
|
+
sage: class MyParent(Parent):
|
|
112
|
+
....: def __init__(self, x):
|
|
113
|
+
....: self.x = x
|
|
114
|
+
....: def __hash__(self):
|
|
115
|
+
....: return hash(self.x)
|
|
116
|
+
sage: class MyUniqueParent(UniqueRepresentation, MyParent): pass
|
|
117
|
+
sage: issubclass(MyUniqueParent, sage.misc.fast_methods.WithEqualityById)
|
|
118
|
+
True
|
|
119
|
+
sage: a = MyUniqueParent(1)
|
|
120
|
+
sage: hash(a) == hash(a.x)
|
|
121
|
+
False
|
|
122
|
+
sage: hash(a) == object.__hash__(a)
|
|
123
|
+
True
|
|
124
|
+
|
|
125
|
+
sage: from sage.misc.fast_methods import WithEqualityById
|
|
126
|
+
sage: o1 = WithEqualityById()
|
|
127
|
+
sage: o2 = WithEqualityById()
|
|
128
|
+
sage: hash(o1) == hash(o2)
|
|
129
|
+
False
|
|
130
|
+
"""
|
|
131
|
+
# This is the default hash function in Python's object.c:
|
|
132
|
+
return hash_by_id(<void *>self)
|
|
133
|
+
|
|
134
|
+
def __richcmp__(self, other, int op):
|
|
135
|
+
"""
|
|
136
|
+
Equality test provided by this class is by identity.
|
|
137
|
+
|
|
138
|
+
TESTS::
|
|
139
|
+
|
|
140
|
+
sage: class MyParent(Parent):
|
|
141
|
+
....: def __init__(self, x):
|
|
142
|
+
....: self.x = x
|
|
143
|
+
....: def __hash__(self):
|
|
144
|
+
....: return hash(self.x)
|
|
145
|
+
sage: class MyUniqueParent(UniqueRepresentation, MyParent): pass
|
|
146
|
+
sage: issubclass(MyUniqueParent, sage.misc.fast_methods.WithEqualityById)
|
|
147
|
+
True
|
|
148
|
+
sage: a = MyUniqueParent(1)
|
|
149
|
+
sage: b = MyUniqueParent(-1)
|
|
150
|
+
|
|
151
|
+
Equality test takes into account identity::
|
|
152
|
+
|
|
153
|
+
sage: a == b
|
|
154
|
+
False
|
|
155
|
+
|
|
156
|
+
When comparing with an object which is not an instance of
|
|
157
|
+
``WithEqualityById``, the other object determines the
|
|
158
|
+
comparison::
|
|
159
|
+
|
|
160
|
+
sage: class AlwaysEqual:
|
|
161
|
+
....: def __eq__(self, other):
|
|
162
|
+
....: return True
|
|
163
|
+
sage: AlwaysEqual() == a
|
|
164
|
+
True
|
|
165
|
+
sage: a == AlwaysEqual()
|
|
166
|
+
True
|
|
167
|
+
|
|
168
|
+
Check that :issue:`19628` is fixed::
|
|
169
|
+
|
|
170
|
+
sage: from sage.misc.lazy_import import LazyImport
|
|
171
|
+
sage: lazyQQ = LazyImport('sage.rings.rational_field', 'QQ')
|
|
172
|
+
sage: PolynomialRing(lazyQQ, 'ijk') is PolynomialRing(QQ, 'ijk')
|
|
173
|
+
True
|
|
174
|
+
sage: PolynomialRing(QQ, 'ijkl') is PolynomialRing(lazyQQ, 'ijkl')
|
|
175
|
+
True
|
|
176
|
+
"""
|
|
177
|
+
# This only makes sense if "other" is also of type WithEqualityById
|
|
178
|
+
if type(self) is not type(other):
|
|
179
|
+
if not isinstance(other, WithEqualityById):
|
|
180
|
+
return NotImplemented
|
|
181
|
+
|
|
182
|
+
if op == Py_EQ:
|
|
183
|
+
return self is other
|
|
184
|
+
elif op == Py_NE:
|
|
185
|
+
return self is not other
|
|
186
|
+
return NotImplemented
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
cdef class FastHashable_class:
|
|
190
|
+
"""
|
|
191
|
+
A class that has a fast hash method, returning a pre-assigned value.
|
|
192
|
+
|
|
193
|
+
.. NOTE::
|
|
194
|
+
|
|
195
|
+
This is for internal use only. The class has a cdef attribute
|
|
196
|
+
``_hash``, that needs to be assigned (for example, by calling
|
|
197
|
+
the init method, or by a direct assignment using
|
|
198
|
+
cython). This is slower than using :func:`provide_hash_by_id`,
|
|
199
|
+
but has the advantage that the hash can be prescribed, by
|
|
200
|
+
assigning a cdef attribute ``_hash``.
|
|
201
|
+
|
|
202
|
+
TESTS::
|
|
203
|
+
|
|
204
|
+
sage: from sage.misc.fast_methods import FastHashable_class
|
|
205
|
+
sage: H = FastHashable_class(123)
|
|
206
|
+
sage: hash(H)
|
|
207
|
+
123
|
|
208
|
+
"""
|
|
209
|
+
def __init__(self, h):
|
|
210
|
+
"""
|
|
211
|
+
TESTS::
|
|
212
|
+
|
|
213
|
+
sage: from sage.misc.fast_methods import FastHashable_class
|
|
214
|
+
sage: H = FastHashable_class(123)
|
|
215
|
+
sage: hash(H) # indirect doctest
|
|
216
|
+
123
|
|
217
|
+
"""
|
|
218
|
+
self._hash = h
|
|
219
|
+
|
|
220
|
+
def __hash__(self):
|
|
221
|
+
"""
|
|
222
|
+
TESTS::
|
|
223
|
+
|
|
224
|
+
sage: from sage.misc.fast_methods import FastHashable_class
|
|
225
|
+
sage: H = FastHashable_class(123)
|
|
226
|
+
sage: hash(H) # indirect doctest
|
|
227
|
+
123
|
|
228
|
+
"""
|
|
229
|
+
return self._hash
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class Singleton(WithEqualityById, metaclass=ClasscallMetaclass):
|
|
233
|
+
"""
|
|
234
|
+
A base class for singletons.
|
|
235
|
+
|
|
236
|
+
A singleton is a class that allows to create not more than a
|
|
237
|
+
single instance. This instance can also belong to a subclass, but
|
|
238
|
+
it is not possible to have several subclasses of a singleton all
|
|
239
|
+
having distinct unique instances.
|
|
240
|
+
|
|
241
|
+
In order to create a singleton, just add :class:`Singleton`
|
|
242
|
+
to the list of base classes::
|
|
243
|
+
|
|
244
|
+
sage: from sage.misc.fast_methods import Singleton
|
|
245
|
+
sage: class C(Singleton, SageObject):
|
|
246
|
+
....: def __init__(self):
|
|
247
|
+
....: print("creating singleton")
|
|
248
|
+
sage: c = C()
|
|
249
|
+
creating singleton
|
|
250
|
+
sage: c2 = C()
|
|
251
|
+
sage: c is c2
|
|
252
|
+
True
|
|
253
|
+
|
|
254
|
+
The unique instance of a singleton stays in memory as long as the
|
|
255
|
+
singleton itself does.
|
|
256
|
+
|
|
257
|
+
Pickling, copying, hashing, and comparison are provided for by
|
|
258
|
+
:class:`Singleton` according to the singleton paradigm. Note
|
|
259
|
+
that pickling fails if the class is replaced by a sub-sub-class
|
|
260
|
+
after creation of the instance::
|
|
261
|
+
|
|
262
|
+
sage: class D(C):
|
|
263
|
+
....: pass
|
|
264
|
+
sage: import __main__ # This is only needed ...
|
|
265
|
+
sage: __main__.C = C # ... in doctests
|
|
266
|
+
sage: __main__.D = D # same here, only in doctests
|
|
267
|
+
sage: orig = type(c)
|
|
268
|
+
sage: c.__class__ = D
|
|
269
|
+
sage: orig == type(c)
|
|
270
|
+
False
|
|
271
|
+
sage: loads(dumps(c))
|
|
272
|
+
Traceback (most recent call last):
|
|
273
|
+
...
|
|
274
|
+
AssertionError: <class '__main__.D'> is not a direct subclass of <class 'sage.misc.fast_methods.Singleton'>
|
|
275
|
+
"""
|
|
276
|
+
@staticmethod
|
|
277
|
+
def __classcall__(cls):
|
|
278
|
+
"""
|
|
279
|
+
Create an instance ``O`` of the given class ``cls``, and make it
|
|
280
|
+
so that in future both ``cls.__call__`` and ``O.__class__.__call__``
|
|
281
|
+
are constant functions returning ``O``.
|
|
282
|
+
|
|
283
|
+
EXAMPLES::
|
|
284
|
+
|
|
285
|
+
sage: from sage.misc.fast_methods import Singleton
|
|
286
|
+
sage: class C(Singleton, Parent):
|
|
287
|
+
....: def __init__(self):
|
|
288
|
+
....: print("creating singleton")
|
|
289
|
+
....: Parent.__init__(self, base=ZZ, category=Rings())
|
|
290
|
+
sage: c = C()
|
|
291
|
+
creating singleton
|
|
292
|
+
sage: import __main__ # This is only needed ...
|
|
293
|
+
sage: __main__.C = C # ... in doctests
|
|
294
|
+
sage: loads(dumps(c)) is copy(c) is C() # indirect doctest
|
|
295
|
+
True
|
|
296
|
+
"""
|
|
297
|
+
assert cls.mro()[1] == Singleton, "{} is not a direct subclass of {}".format(cls, Singleton)
|
|
298
|
+
res = typecall(cls)
|
|
299
|
+
cf = ConstantFunction(res)
|
|
300
|
+
cls._set_classcall(cf)
|
|
301
|
+
res.__class__._set_classcall(cf)
|
|
302
|
+
return res
|
|
303
|
+
|
|
304
|
+
def __copy__(self):
|
|
305
|
+
"""
|
|
306
|
+
There is a unique instance of a singleton, hence, copying
|
|
307
|
+
returns ``self``.
|
|
308
|
+
|
|
309
|
+
EXAMPLES::
|
|
310
|
+
|
|
311
|
+
sage: from sage.misc.fast_methods import Singleton
|
|
312
|
+
sage: class C(Singleton, Parent):
|
|
313
|
+
....: def __init__(self):
|
|
314
|
+
....: print("creating singleton")
|
|
315
|
+
....: Parent.__init__(self, base=ZZ, category=Rings())
|
|
316
|
+
sage: c = C()
|
|
317
|
+
creating singleton
|
|
318
|
+
sage: import __main__ # This is only needed ...
|
|
319
|
+
sage: __main__.C = C # ... in doctests
|
|
320
|
+
sage: loads(dumps(c)) is copy(c) is C() # indirect doctest
|
|
321
|
+
True
|
|
322
|
+
"""
|
|
323
|
+
return self
|
|
324
|
+
|
|
325
|
+
def __reduce__(self):
|
|
326
|
+
"""
|
|
327
|
+
There is a unique instance of a singleton, hence, pickling
|
|
328
|
+
returns ``self``.
|
|
329
|
+
|
|
330
|
+
EXAMPLES::
|
|
331
|
+
|
|
332
|
+
sage: from sage.misc.fast_methods import Singleton
|
|
333
|
+
sage: class C(Singleton, Parent):
|
|
334
|
+
....: def __init__(self):
|
|
335
|
+
....: print("creating singleton")
|
|
336
|
+
....: Parent.__init__(self, base=ZZ, category=Rings())
|
|
337
|
+
....:
|
|
338
|
+
sage: c = C()
|
|
339
|
+
creating singleton
|
|
340
|
+
sage: import __main__ # This is only needed ...
|
|
341
|
+
sage: __main__.C = C # ... in doctests
|
|
342
|
+
sage: loads(dumps(c)) is copy(c) is C() # indirect doctest
|
|
343
|
+
True
|
|
344
|
+
|
|
345
|
+
The pickle data mainly consist of the class of the unique instance,
|
|
346
|
+
which may be a subclass of the original class used to create the
|
|
347
|
+
instance.If the class is replaced by a sub-sub-class after creation
|
|
348
|
+
of the instance, pickling fails. See the doctest
|
|
349
|
+
in :class:`Singleton`.
|
|
350
|
+
"""
|
|
351
|
+
return self.__class__, ()
|
sage/misc/flatten.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
"Flatten nested lists"
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def flatten(in_list, ltypes=(list, tuple), max_level=sys.maxsize):
|
|
8
|
+
"""
|
|
9
|
+
Flatten a nested list.
|
|
10
|
+
|
|
11
|
+
INPUT:
|
|
12
|
+
|
|
13
|
+
- ``in_list`` -- list or tuple
|
|
14
|
+
- ``ltypes`` -- (optional) list of particular types to flatten
|
|
15
|
+
- ``max_level`` -- the maximum level to flatten
|
|
16
|
+
|
|
17
|
+
OUTPUT: a flat list of the entries of ``in_list``
|
|
18
|
+
|
|
19
|
+
EXAMPLES::
|
|
20
|
+
|
|
21
|
+
sage: flatten([[1,1],[1],2])
|
|
22
|
+
[1, 1, 1, 2]
|
|
23
|
+
sage: flatten([[1,2,3], (4,5), [[[1],[2]]]])
|
|
24
|
+
[1, 2, 3, 4, 5, 1, 2]
|
|
25
|
+
sage: flatten([[1,2,3], (4,5), [[[1],[2]]]], max_level=1)
|
|
26
|
+
[1, 2, 3, 4, 5, [[1], [2]]]
|
|
27
|
+
sage: flatten([[[3],[]]],max_level=0)
|
|
28
|
+
[[[3], []]]
|
|
29
|
+
sage: flatten([[[3],[]]],max_level=1)
|
|
30
|
+
[[3], []]
|
|
31
|
+
sage: flatten([[[3],[]]],max_level=2)
|
|
32
|
+
[3]
|
|
33
|
+
|
|
34
|
+
In the following example, the vector is not flattened because
|
|
35
|
+
it is not given in the ``ltypes`` input. ::
|
|
36
|
+
|
|
37
|
+
sage: flatten((['Hi', 2, vector(QQ, [1,2,3])], (4,5,6))) # needs sage.modules
|
|
38
|
+
['Hi', 2, (1, 2, 3), 4, 5, 6]
|
|
39
|
+
|
|
40
|
+
We give the vector type and then even the vector gets flattened::
|
|
41
|
+
|
|
42
|
+
sage: tV = sage.modules.vector_rational_dense.Vector_rational_dense # needs sage.modules
|
|
43
|
+
sage: flatten((['Hi', 2, vector(QQ, [1,2,3])], (4,5,6)), # needs sage.modules
|
|
44
|
+
....: ltypes=(list, tuple, tV))
|
|
45
|
+
['Hi', 2, 1, 2, 3, 4, 5, 6]
|
|
46
|
+
|
|
47
|
+
We flatten a finite field. ::
|
|
48
|
+
|
|
49
|
+
sage: flatten(GF(5))
|
|
50
|
+
[0, 1, 2, 3, 4]
|
|
51
|
+
sage: flatten([GF(5)])
|
|
52
|
+
[Finite Field of size 5]
|
|
53
|
+
sage: tGF = type(GF(5))
|
|
54
|
+
sage: flatten([GF(5)], ltypes=(list, tuple, tGF))
|
|
55
|
+
[0, 1, 2, 3, 4]
|
|
56
|
+
|
|
57
|
+
Degenerate cases::
|
|
58
|
+
|
|
59
|
+
sage: flatten([[],[]])
|
|
60
|
+
[]
|
|
61
|
+
sage: flatten([[[]]])
|
|
62
|
+
[]
|
|
63
|
+
"""
|
|
64
|
+
index = 0
|
|
65
|
+
current_level = 0
|
|
66
|
+
new_list = list(in_list)
|
|
67
|
+
level_list = [0] * len(in_list)
|
|
68
|
+
|
|
69
|
+
while index < len(new_list):
|
|
70
|
+
len_v = True
|
|
71
|
+
while isinstance(new_list[index], ltypes) and current_level < max_level:
|
|
72
|
+
v = list(new_list[index])
|
|
73
|
+
len_v = len(v)
|
|
74
|
+
new_list[index: index + 1] = v
|
|
75
|
+
old_level = level_list[index]
|
|
76
|
+
level_list[index: index + 1] = [0] * len_v
|
|
77
|
+
if len_v:
|
|
78
|
+
current_level += 1
|
|
79
|
+
level_list[index + len_v - 1] = old_level + 1
|
|
80
|
+
else:
|
|
81
|
+
current_level -= old_level
|
|
82
|
+
index -= 1
|
|
83
|
+
break
|
|
84
|
+
|
|
85
|
+
# If len_v == 0, then index points to a previous element, so we
|
|
86
|
+
# do not need to do anything.
|
|
87
|
+
if len_v:
|
|
88
|
+
current_level -= level_list[index]
|
|
89
|
+
index += 1
|
|
90
|
+
return new_list
|
|
Binary file
|
sage/misc/fpickle.pyx
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
# cython: old_style_globals=True
|
|
3
|
+
# cython: binding=True
|
|
4
|
+
"""
|
|
5
|
+
Function pickling
|
|
6
|
+
|
|
7
|
+
REFERENCE: The python cookbook.
|
|
8
|
+
"""
|
|
9
|
+
import copyreg
|
|
10
|
+
import pickle
|
|
11
|
+
import sys
|
|
12
|
+
import types
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def code_ctor(*args):
|
|
16
|
+
"""
|
|
17
|
+
EXAMPLES:
|
|
18
|
+
|
|
19
|
+
This indirectly tests this function. ::
|
|
20
|
+
|
|
21
|
+
sage: def foo(a, b, c=10): return a+b+c
|
|
22
|
+
sage: sage.misc.fpickle.reduce_code(foo.__code__)
|
|
23
|
+
(<cyfunction code_ctor at ...>, ...)
|
|
24
|
+
sage: unpickle_function(pickle_function(foo))
|
|
25
|
+
<function foo at ...>
|
|
26
|
+
"""
|
|
27
|
+
return types.CodeType(*args)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def reduce_code(co):
|
|
31
|
+
"""
|
|
32
|
+
EXAMPLES::
|
|
33
|
+
|
|
34
|
+
sage: def foo(N): return N+1
|
|
35
|
+
sage: sage.misc.fpickle.reduce_code(foo.__code__)
|
|
36
|
+
(<cyfunction code_ctor at ...>, ...)
|
|
37
|
+
|
|
38
|
+
Test that the constructed code matches the original code::
|
|
39
|
+
|
|
40
|
+
sage: ctor, args = sage.misc.fpickle.reduce_code(foo.__code__)
|
|
41
|
+
sage: ctor(*args) == foo.__code__
|
|
42
|
+
True
|
|
43
|
+
"""
|
|
44
|
+
if co.co_freevars or co.co_cellvars:
|
|
45
|
+
raise ValueError("Cannot pickle code objects from closures")
|
|
46
|
+
|
|
47
|
+
co_args = (co.co_argcount,)
|
|
48
|
+
co_args += (co.co_posonlyargcount,)
|
|
49
|
+
co_args += (co.co_kwonlyargcount, co.co_nlocals,
|
|
50
|
+
co.co_stacksize, co.co_flags, co.co_code,
|
|
51
|
+
co.co_consts, co.co_names, co.co_varnames, co.co_filename,
|
|
52
|
+
co.co_name)
|
|
53
|
+
if sys.version_info.minor >= 11:
|
|
54
|
+
co_args += (co.co_qualname, co.co_firstlineno,
|
|
55
|
+
co.co_linetable, co.co_exceptiontable)
|
|
56
|
+
else:
|
|
57
|
+
co_args += (co.co_firstlineno, co.co_lnotab)
|
|
58
|
+
|
|
59
|
+
return (code_ctor, co_args)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
copyreg.pickle(types.CodeType, reduce_code)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def pickle_function(func):
|
|
66
|
+
"""
|
|
67
|
+
Pickle the Python function func. This is not a normal pickle; you
|
|
68
|
+
must use the unpickle_function method to unpickle the pickled
|
|
69
|
+
function.
|
|
70
|
+
|
|
71
|
+
NOTE: This does not work on all functions, but does work on
|
|
72
|
+
'surprisingly' many functions. In particular, it does not
|
|
73
|
+
work on functions that includes nested functions.
|
|
74
|
+
|
|
75
|
+
INPUT:
|
|
76
|
+
|
|
77
|
+
- ``func`` -- a Python function
|
|
78
|
+
|
|
79
|
+
OUTPUT: string
|
|
80
|
+
|
|
81
|
+
EXAMPLES::
|
|
82
|
+
|
|
83
|
+
sage: def f(N): return N+1
|
|
84
|
+
...
|
|
85
|
+
sage: g = pickle_function(f)
|
|
86
|
+
sage: h = unpickle_function(g)
|
|
87
|
+
sage: h(10)
|
|
88
|
+
11
|
|
89
|
+
"""
|
|
90
|
+
return pickle.dumps(func.__code__)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def unpickle_function(pickled):
|
|
94
|
+
"""
|
|
95
|
+
Unpickle a pickled function.
|
|
96
|
+
|
|
97
|
+
EXAMPLES::
|
|
98
|
+
|
|
99
|
+
sage: def f(N, M): return N*M
|
|
100
|
+
...
|
|
101
|
+
sage: unpickle_function(pickle_function(f))(3,5)
|
|
102
|
+
15
|
|
103
|
+
"""
|
|
104
|
+
recovered = pickle.loads(pickled)
|
|
105
|
+
return types.FunctionType(recovered, globals())
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def call_pickled_function(fpargs):
|
|
109
|
+
try:
|
|
110
|
+
import sage.all as toplevel
|
|
111
|
+
except ImportError:
|
|
112
|
+
import sage.all__sagemath_categories as toplevel
|
|
113
|
+
(fp, (args, kwds)) = fpargs
|
|
114
|
+
f = eval("unpickle_function(fp)", toplevel.__dict__, {'fp': fp})
|
|
115
|
+
res = eval("f(*args, **kwds)", toplevel.__dict__,
|
|
116
|
+
{'args': args, 'kwds': kwds, 'f': f})
|
|
117
|
+
return ((args, kwds), res)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# The following four methods are taken from twisted.persisted.styles - the
|
|
121
|
+
# import of twisted.persisted.styles takes a long time and we do not use
|
|
122
|
+
# most functionality it provides
|
|
123
|
+
def pickleMethod(method):
|
|
124
|
+
'support function for copyreg to pickle method refs'
|
|
125
|
+
|
|
126
|
+
if isinstance(method.__self__, type):
|
|
127
|
+
# This is a class method, so get it from the type directly
|
|
128
|
+
return (getattr, (method.__self__, method.__func__.__name__))
|
|
129
|
+
else:
|
|
130
|
+
cls = method.__self__.__class__
|
|
131
|
+
return (unpickleMethod, (method.__func__.__name__, method.__self__, cls))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def unpickleMethod(im_name,
|
|
135
|
+
__self__,
|
|
136
|
+
im_class):
|
|
137
|
+
'support function for copyreg to unpickle method refs'
|
|
138
|
+
try:
|
|
139
|
+
unbound = getattr(im_class, im_name)
|
|
140
|
+
if __self__ is None:
|
|
141
|
+
return unbound
|
|
142
|
+
|
|
143
|
+
bound = types.MethodType(unbound, __self__)
|
|
144
|
+
return bound
|
|
145
|
+
except AttributeError:
|
|
146
|
+
assert __self__ is not None, "No recourse: no instance to guess from."
|
|
147
|
+
# Attempt a common fix before bailing -- if classes have
|
|
148
|
+
# changed around since we pickled this method, we may still be
|
|
149
|
+
# able to get it by looking on the instance's current class.
|
|
150
|
+
unbound = getattr(__self__.__class__, im_name)
|
|
151
|
+
|
|
152
|
+
bound = types.MethodType(unbound, __self__)
|
|
153
|
+
return bound
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
copyreg.pickle(types.MethodType,
|
|
157
|
+
pickleMethod,
|
|
158
|
+
unpickleMethod)
|
|
159
|
+
|
|
160
|
+
oldModules = {}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def pickleModule(module):
|
|
164
|
+
'support function for copyreg to pickle module refs'
|
|
165
|
+
return unpickleModule, (module.__name__,)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def unpickleModule(name):
|
|
169
|
+
'support function for copyreg to unpickle module refs'
|
|
170
|
+
if name in oldModules:
|
|
171
|
+
name = oldModules[name]
|
|
172
|
+
return __import__(name, {}, {}, 'x')
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
copyreg.pickle(types.ModuleType,
|
|
176
|
+
pickleModule,
|
|
177
|
+
unpickleModule)
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-objects
|
|
2
|
+
cdef class ArgumentFixer:
|
|
3
|
+
cdef public object f
|
|
4
|
+
cdef public int _ndefault
|
|
5
|
+
cdef public int _nargs
|
|
6
|
+
cdef tuple _arg_names
|
|
7
|
+
cdef bint _classmethod
|
|
8
|
+
cdef dict _defaults
|
|
9
|
+
cdef public tuple _default_tuple
|
|
10
|
+
|
|
11
|
+
cdef fix_to_pos_args_kwds(self, tuple args, dict kwargs)
|