pyobject 1.3.3__tar.gz → 1.3.4__tar.gz
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.
- {pyobject-1.3.3/pyobject.egg-info → pyobject-1.3.4}/PKG-INFO +16 -8
- {pyobject-1.3.3 → pyobject-1.3.4}/README.rst +14 -6
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/__init__.py +2 -3
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/browser.py +1 -1
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/code.py +1 -1
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/pyobj_extension.c +30 -24
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/search.py +1 -1
- {pyobject-1.3.3 → pyobject-1.3.4/pyobject.egg-info}/PKG-INFO +16 -8
- {pyobject-1.3.3 → pyobject-1.3.4}/LICENSE +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/MANIFEST.in +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/back.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/codeobject.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/dict.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/empty_dict.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/empty_list.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/empty_tuple.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/forward.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/function.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/list.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/number.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/python.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/python.ico +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/refresh.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/string.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/images/tuple.gif +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/objproxy/__init__.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/objproxy/builtin_hook.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/objproxy/optimize.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/objproxy/utils.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/tests/test_code.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/tests/test_objproxy.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject/tests/test_objproxy_perf.py +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject.egg-info/SOURCES.txt +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject.egg-info/dependency_links.txt +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject.egg-info/requires.txt +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/pyobject.egg-info/top_level.txt +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/setup.cfg +0 -0
- {pyobject-1.3.3 → pyobject-1.3.4}/setup.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobject
|
|
3
|
-
Version: 1.3.
|
|
4
|
-
Summary: A multifunctional all-in-one utility tool for managing internal Python objects, compatible with nearly all Python 3 versions.
|
|
3
|
+
Version: 1.3.4
|
|
4
|
+
Summary: A multifunctional all-in-one utility tool for managing internal Python objects, compatible with nearly all Python 3 versions.
|
|
5
5
|
Home-page: https://github.com/ekcbw/pyobject
|
|
6
6
|
Author: ekcbw
|
|
7
7
|
Author-email: u81430728@163.com
|
|
@@ -28,7 +28,8 @@ Dynamic: summary
|
|
|
28
28
|
|Stars| |GitHub release| |License: MIT|
|
|
29
29
|
|
|
30
30
|
pyobject - A multifunctional all-in-one utility tool for managing
|
|
31
|
-
internal Python objects, compatible with nearly all Python 3 versions
|
|
31
|
+
internal Python objects, compatible with nearly all Python 3 versions
|
|
32
|
+
and all platforms (Windows, Linux, macOS, etc.).
|
|
32
33
|
|
|
33
34
|
[English \| `中文 <README_zh.md>`__]
|
|
34
35
|
|
|
@@ -496,20 +497,27 @@ In the GIL-free version of Python 3.13+, get and set reference counts,
|
|
|
496
497
|
where ``ref_data`` is ``(ob_ref_local, ob_ref_shared)``, without
|
|
497
498
|
considering the reference counts added during the call.
|
|
498
499
|
|
|
499
|
-
*Warning: Improper use of these functions above may lead to
|
|
500
|
+
*Warning: Improper use of these functions above may lead to crash of the
|
|
501
|
+
intepreter.*
|
|
500
502
|
|
|
501
503
|
**list_in(obj, lst)**:
|
|
502
504
|
|
|
503
505
|
Determine whether obj is in the sequence lst. Compared to the built-in
|
|
504
|
-
Python call
|
|
505
|
-
multiple times, this function directly compares the
|
|
506
|
-
|
|
506
|
+
Python call ``obj in lst`` that invokes the ``==`` operator
|
|
507
|
+
(``__eq__()``) multiple times, this function directly compares the
|
|
508
|
+
pointers to improve the performance.
|
|
507
509
|
|
|
508
|
-
**
|
|
510
|
+
**get_string_intern_dict()**:
|
|
511
|
+
|
|
512
|
+
Return the internal dictionary for interning strings (``sys.intern()``).
|
|
513
|
+
|
|
514
|
+
**Current ``pyobject`` Version**: 1.3.4
|
|
509
515
|
|
|
510
516
|
Change Log
|
|
511
517
|
----------
|
|
512
518
|
|
|
519
|
+
| 2026-1-22(v1.3.4): Added ``get_string_intern_dict()`` to
|
|
520
|
+
``pyobject.pyobj_extension`` module (available for 3.12+).
|
|
513
521
|
| 2026-1-4(v1.3.3): Improved the support for Python 3.14 and
|
|
514
522
|
``describe()`` function. Adjusted the minimum supported Python version
|
|
515
523
|
to 3.6.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|Stars| |GitHub release| |License: MIT|
|
|
2
2
|
|
|
3
3
|
pyobject - A multifunctional all-in-one utility tool for managing
|
|
4
|
-
internal Python objects, compatible with nearly all Python 3 versions
|
|
4
|
+
internal Python objects, compatible with nearly all Python 3 versions
|
|
5
|
+
and all platforms (Windows, Linux, macOS, etc.).
|
|
5
6
|
|
|
6
7
|
[English \| `中文 <README_zh.md>`__]
|
|
7
8
|
|
|
@@ -469,20 +470,27 @@ In the GIL-free version of Python 3.13+, get and set reference counts,
|
|
|
469
470
|
where ``ref_data`` is ``(ob_ref_local, ob_ref_shared)``, without
|
|
470
471
|
considering the reference counts added during the call.
|
|
471
472
|
|
|
472
|
-
*Warning: Improper use of these functions above may lead to
|
|
473
|
+
*Warning: Improper use of these functions above may lead to crash of the
|
|
474
|
+
intepreter.*
|
|
473
475
|
|
|
474
476
|
**list_in(obj, lst)**:
|
|
475
477
|
|
|
476
478
|
Determine whether obj is in the sequence lst. Compared to the built-in
|
|
477
|
-
Python call
|
|
478
|
-
multiple times, this function directly compares the
|
|
479
|
-
|
|
479
|
+
Python call ``obj in lst`` that invokes the ``==`` operator
|
|
480
|
+
(``__eq__()``) multiple times, this function directly compares the
|
|
481
|
+
pointers to improve the performance.
|
|
480
482
|
|
|
481
|
-
**
|
|
483
|
+
**get_string_intern_dict()**:
|
|
484
|
+
|
|
485
|
+
Return the internal dictionary for interning strings (``sys.intern()``).
|
|
486
|
+
|
|
487
|
+
**Current ``pyobject`` Version**: 1.3.4
|
|
482
488
|
|
|
483
489
|
Change Log
|
|
484
490
|
----------
|
|
485
491
|
|
|
492
|
+
| 2026-1-22(v1.3.4): Added ``get_string_intern_dict()`` to
|
|
493
|
+
``pyobject.pyobj_extension`` module (available for 3.12+).
|
|
486
494
|
| 2026-1-4(v1.3.3): Improved the support for Python 3.14 and
|
|
487
495
|
``describe()`` function. Adjusted the minimum supported Python version
|
|
488
496
|
to 3.6.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""A multifunctional all-in-one utility tool for managing internal Python \
|
|
2
2
|
objects, compatible with nearly all Python 3 versions.
|
|
3
|
-
一个多功能合一的提供操作Python对象底层工具的Python包, 支持几乎所有Python 3版本。
|
|
4
3
|
"""
|
|
5
4
|
import sys, types
|
|
6
5
|
from warnings import warn
|
|
@@ -14,7 +13,7 @@ except ImportError: # 低于3.7的版本
|
|
|
14
13
|
MethodDescriptorType
|
|
15
14
|
ClassMethodDescriptorType = type(dict.__dict__['fromkeys'])
|
|
16
15
|
|
|
17
|
-
__version__="1.3.
|
|
16
|
+
__version__="1.3.4"
|
|
18
17
|
|
|
19
18
|
__all__=["objectname","bases","describe","desc"]
|
|
20
19
|
_always_ignored_names=["__builtins__","__doc__"]
|
|
@@ -134,7 +133,7 @@ try:
|
|
|
134
133
|
"setrefcount","list_in","getrefcount_nogil","setrefcount_nogil",
|
|
135
134
|
"get_type_flag","set_type_flag","set_type_base","set_type_bases",
|
|
136
135
|
"set_type_mro","get_type_subclasses","set_type_subclasses",
|
|
137
|
-
"set_type_subclasses_by_cls"])
|
|
136
|
+
"set_type_subclasses_by_cls","get_string_intern_dict"])
|
|
138
137
|
except ImportError:warn("Failed to import pyobject.pyobj_extension.")
|
|
139
138
|
try:
|
|
140
139
|
from pyobject.objproxy import ObjChain,ProxiedObj,unproxy_obj
|
|
@@ -1,48 +1,41 @@
|
|
|
1
|
-
#include <
|
|
2
|
-
#include <
|
|
1
|
+
#include <stdint.h>
|
|
2
|
+
#include <Python.h>
|
|
3
3
|
|
|
4
|
-
PyDoc_STRVAR(convptr_doc, u8"convptr(pointer)"
|
|
4
|
+
PyDoc_STRVAR(convptr_doc, u8"convptr(pointer) -> object"
|
|
5
5
|
u8"\n"
|
|
6
6
|
u8"Convert a integer pointer to a Python object, as a reverse of id()."
|
|
7
|
-
u8"将整数指针转换为Python对象,与id()相反。\n"
|
|
8
7
|
u8"Warning:Converting an invalid pointer may lead to crashes.");
|
|
9
8
|
PyDoc_STRVAR(py_inc_doc, u8"py_incref(obj)"
|
|
10
9
|
u8"\n"
|
|
11
10
|
u8"Increase the reference count of an object."
|
|
12
|
-
u8"将对象的引用计数增加1。\n"
|
|
13
11
|
u8"Warning:Improper use of this function may lead to crashes.");
|
|
14
12
|
PyDoc_STRVAR(py_dec_doc, u8"py_decref(obj)"
|
|
15
13
|
u8"\n"
|
|
16
14
|
u8"Decrease the reference count of an object."
|
|
17
|
-
u8"将对象的引用计数减小1。\n"
|
|
18
15
|
u8"Warning:Improper use of this function may lead to crashes.");
|
|
19
|
-
PyDoc_STRVAR(getrealref_doc, u8"getrealrefcount(obj)"
|
|
16
|
+
PyDoc_STRVAR(getrealref_doc, u8"getrealrefcount(obj) -> int"
|
|
20
17
|
u8"\n"
|
|
21
18
|
u8"Get the actual reference count of an object before calling getrealrefcount(). Unlike "
|
|
22
|
-
u8"sys.getrefcount(), this function ignores the reference count increase when called.\n"
|
|
23
|
-
|
|
24
|
-
PyDoc_STRVAR(setref_doc, u8"setrefcount(obj, n)"
|
|
19
|
+
u8"sys.getrefcount(), this function ignores the reference count increase when called.\n");
|
|
20
|
+
PyDoc_STRVAR(setref_doc, u8"setrefcount(obj, n: int)"
|
|
25
21
|
u8"\n"
|
|
26
22
|
u8"Set the actual reference count of an object before calling setrefcount() to n, "
|
|
27
23
|
u8"as a reverse of getrealrefcount(), ignoring the reference count increase when called.\n"
|
|
28
|
-
u8"
|
|
29
|
-
u8"Warning:Improper use of this function may lead to crashes.");
|
|
24
|
+
u8"Warning: Improper use of this function may lead to crashes.");
|
|
30
25
|
PyDoc_STRVAR(list_in_doc, u8"list_in(obj, lst)"
|
|
31
26
|
u8"\n"
|
|
32
|
-
u8"判断obj是否在列表或元组lst中。\n与Python内置的obj in lst调用多次\"==\"运算符(__eq__)相比,"
|
|
33
|
-
u8"本函数直接比较对象的指针,提高了效率。\n"
|
|
34
27
|
u8"Determine whether `obj` is in the sequence `lst`.\nCompared to the built-in "
|
|
35
28
|
u8"Python call `obj in lst` that invokes the `==` operator (__eq__) multiple times, "
|
|
36
29
|
u8"this function directly compares the pointers to improve efficiency.");
|
|
37
|
-
PyDoc_STRVAR(getrefcount_nogil_doc, u8"getrefcount_nogil(obj)\n"
|
|
38
|
-
u8"
|
|
39
|
-
u8"Get the reference counts in GIL-free versions of Python 3.14+, returning a tuple of "
|
|
30
|
+
PyDoc_STRVAR(getrefcount_nogil_doc, u8"getrefcount_nogil(obj) -> tuple[int, int]\n"
|
|
31
|
+
u8"Get the reference counts in GIL-free versions of Python 3.13+, returning a tuple of "
|
|
40
32
|
u8"(ob_ref_local, ob_ref_shared), ignoring the reference count increase when called.");
|
|
41
|
-
PyDoc_STRVAR(setrefcount_nogil_doc, u8"setrefcount_nogil(obj,ref_data)\n"
|
|
42
|
-
u8"
|
|
43
|
-
u8"Set the reference counts in GIL-free versions of Python 3.14+, with ref_data being a tuple of "
|
|
33
|
+
PyDoc_STRVAR(setrefcount_nogil_doc, u8"setrefcount_nogil(obj, ref_data: tuple[int, int])\n"
|
|
34
|
+
u8"Set the reference counts in GIL-free versions of Python 3.13+, with ref_data being a tuple of "
|
|
44
35
|
u8"(ob_ref_local, ob_ref_shared), ignoring the reference count increase when called.\n"
|
|
45
|
-
u8"Warning:Improper use of this function may lead to crashes.");
|
|
36
|
+
u8"Warning: Improper use of this function may lead to crashes.");
|
|
37
|
+
PyDoc_STRVAR(get_string_intern_doc, u8"get_string_intern_dict() -> dict[str, str]\n"
|
|
38
|
+
u8"Return the internal dictionary for interning strings (sys.intern()).");
|
|
46
39
|
|
|
47
40
|
#if PY_MAJOR_VERSION < 3
|
|
48
41
|
#error "Python 3 is required"
|
|
@@ -217,7 +210,7 @@ PyObject *list_in(PyObject *self, PyObject *args, PyObject *kwargs) {
|
|
|
217
210
|
Py_RETURN_FALSE;
|
|
218
211
|
}
|
|
219
212
|
PyObject *_list_setnull(PyObject *self, PyObject *args) {
|
|
220
|
-
PyObject *list;Py_ssize_t index;
|
|
213
|
+
PyObject *list; Py_ssize_t index;
|
|
221
214
|
if (!PyArg_ParseTuple(args, "On", &list, &index)) return NULL;
|
|
222
215
|
if (!PyList_Check(list)) {
|
|
223
216
|
PyErr_SetString(PyExc_TypeError, "expected a list");
|
|
@@ -289,10 +282,22 @@ static PyObject* set_type_mro(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
289
282
|
Py_RETURN_NONE;
|
|
290
283
|
}
|
|
291
284
|
|
|
285
|
+
static PyObject* get_string_intern_dict(PyObject *self, PyObject *args) {
|
|
286
|
+
#ifndef _Py_INTERP_CACHED_OBJECT
|
|
287
|
+
PyErr_SetString(PyExc_NotImplementedError, "CPython 3.12+ is required");
|
|
288
|
+
return NULL;
|
|
289
|
+
#else
|
|
290
|
+
PyInterpreterState *interp = _PyInterpreterState_GET();
|
|
291
|
+
PyObject *result = _Py_INTERP_CACHED_OBJECT(interp, interned_strings);
|
|
292
|
+
Py_INCREF(result);
|
|
293
|
+
return result;
|
|
294
|
+
#endif
|
|
295
|
+
}
|
|
296
|
+
|
|
292
297
|
#ifdef _PY312
|
|
293
298
|
#define managed_static_type_state static_builtin_state /* 兼容3.12 */
|
|
294
299
|
#endif
|
|
295
|
-
PyObject **_lookup_tp_subclasses(PyTypeObject *self){ //
|
|
300
|
+
PyObject **_lookup_tp_subclasses(PyTypeObject *self){ // 来自解释器的实现typeobject.c
|
|
296
301
|
#ifdef _PY312PLUS
|
|
297
302
|
if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
|
|
298
303
|
PyInterpreterState *interp = _PyInterpreterState_GET();
|
|
@@ -412,6 +417,7 @@ static PyMethodDef pyobj_extension_functions[] = {
|
|
|
412
417
|
{"set_type_subclasses", (PyCFunction)set_type_subclasses, METH_VARARGS | METH_KEYWORDS, "set_type_subclasses(typeobj: type, subclasses: dict)"},
|
|
413
418
|
{"set_type_subclasses_by_cls", (PyCFunction)set_type_subclasses_by_cls, METH_VARARGS | METH_KEYWORDS,
|
|
414
419
|
"set_type_subclasses_by_cls(typeobj: type, cls: type)"},
|
|
420
|
+
{"get_string_intern_dict", (PyCFunction)get_string_intern_dict, METH_NOARGS, get_string_intern_doc},
|
|
415
421
|
{ NULL, NULL, 0, NULL } /* marks end of array */
|
|
416
422
|
};
|
|
417
423
|
|
|
@@ -429,7 +435,7 @@ int exec_pyobj_extension(PyObject *module) {
|
|
|
429
435
|
}
|
|
430
436
|
|
|
431
437
|
/* Documentation for pyobj_extension. */
|
|
432
|
-
PyDoc_STRVAR(pyobj_extension_doc, u8"
|
|
438
|
+
PyDoc_STRVAR(pyobj_extension_doc, u8"Provide the functions for manipulating underlying Python objects.");
|
|
433
439
|
|
|
434
440
|
static PyModuleDef_Slot pyobj_extension_slots[] = {
|
|
435
441
|
{Py_mod_exec, exec_pyobj_extension},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobject
|
|
3
|
-
Version: 1.3.
|
|
4
|
-
Summary: A multifunctional all-in-one utility tool for managing internal Python objects, compatible with nearly all Python 3 versions.
|
|
3
|
+
Version: 1.3.4
|
|
4
|
+
Summary: A multifunctional all-in-one utility tool for managing internal Python objects, compatible with nearly all Python 3 versions.
|
|
5
5
|
Home-page: https://github.com/ekcbw/pyobject
|
|
6
6
|
Author: ekcbw
|
|
7
7
|
Author-email: u81430728@163.com
|
|
@@ -28,7 +28,8 @@ Dynamic: summary
|
|
|
28
28
|
|Stars| |GitHub release| |License: MIT|
|
|
29
29
|
|
|
30
30
|
pyobject - A multifunctional all-in-one utility tool for managing
|
|
31
|
-
internal Python objects, compatible with nearly all Python 3 versions
|
|
31
|
+
internal Python objects, compatible with nearly all Python 3 versions
|
|
32
|
+
and all platforms (Windows, Linux, macOS, etc.).
|
|
32
33
|
|
|
33
34
|
[English \| `中文 <README_zh.md>`__]
|
|
34
35
|
|
|
@@ -496,20 +497,27 @@ In the GIL-free version of Python 3.13+, get and set reference counts,
|
|
|
496
497
|
where ``ref_data`` is ``(ob_ref_local, ob_ref_shared)``, without
|
|
497
498
|
considering the reference counts added during the call.
|
|
498
499
|
|
|
499
|
-
*Warning: Improper use of these functions above may lead to
|
|
500
|
+
*Warning: Improper use of these functions above may lead to crash of the
|
|
501
|
+
intepreter.*
|
|
500
502
|
|
|
501
503
|
**list_in(obj, lst)**:
|
|
502
504
|
|
|
503
505
|
Determine whether obj is in the sequence lst. Compared to the built-in
|
|
504
|
-
Python call
|
|
505
|
-
multiple times, this function directly compares the
|
|
506
|
-
|
|
506
|
+
Python call ``obj in lst`` that invokes the ``==`` operator
|
|
507
|
+
(``__eq__()``) multiple times, this function directly compares the
|
|
508
|
+
pointers to improve the performance.
|
|
507
509
|
|
|
508
|
-
**
|
|
510
|
+
**get_string_intern_dict()**:
|
|
511
|
+
|
|
512
|
+
Return the internal dictionary for interning strings (``sys.intern()``).
|
|
513
|
+
|
|
514
|
+
**Current ``pyobject`` Version**: 1.3.4
|
|
509
515
|
|
|
510
516
|
Change Log
|
|
511
517
|
----------
|
|
512
518
|
|
|
519
|
+
| 2026-1-22(v1.3.4): Added ``get_string_intern_dict()`` to
|
|
520
|
+
``pyobject.pyobj_extension`` module (available for 3.12+).
|
|
513
521
|
| 2026-1-4(v1.3.3): Improved the support for Python 3.14 and
|
|
514
522
|
``describe()`` function. Adjusted the minimum supported Python version
|
|
515
523
|
to 3.6.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|