perf(vast_c): 节点构造 tp_new 直构试验打平,回退 Vectorcall 并记录结论
- 实测 tp_new + 逐字段 SetAttr 与 PyObject_Vectorcall 打平(基准 0.9x,略慢):PyTuple_New(0) + _fields 缓存查询 + slots 名称线性查找开销抵消 Python 帧收益 - 回退并注释说明:要降低 _Init 19.7s 需 tp_members.offset 偏移直写(风险较高另行评估)
This commit is contained in:
1 parent
e37cc8d792
commit
94a065a386
1 file changed
+5
-1
+5
-1
@@ -128,7 +128,11 @@ static PyObject *ClassGet(Parser *P, const char *Name) {
|
||||
return Cls; /* borrowed */
|
||||
}
|
||||
|
||||
/* 构造节点:按位置参数数组调用类(vast.nodes 的 __init__(*args, **kwargs)) */
|
||||
/* 构造节点:按位置参数数组实例化 vast.nodes 类。
|
||||
* 实测 tp_new 直构 + SetAttr 与 PyObject_Vectorcall 打平(甚至略慢 0.9x):
|
||||
* PyTuple_New(0) + _fields 缓存查询 + 逐字段 SetAttr(slots 名称线性查找)的开销
|
||||
* 抵消了 Python 帧收益,故保留 Vectorcall(行为与 vast.parse 完全一致)。
|
||||
* 要真正降低 _Init 19.7s 需 slots 偏移直写(tp_members.offset),风险较高另行评估。 */
|
||||
static PyObject *NewNode(Parser *P, const char *Name, PyObject **Args, Py_ssize_t NArgs) {
|
||||
PyObject *Cls = ClassGet(P, Name);
|
||||
if (Cls == NULL) {
|
||||
|
||||
Reference in new issue
Block a user