[Bf-blender-cvs] [728cffa9ce5] master: PyAPI: fast keyword parsing for bpy.props

Campbell Barton noreply at git.blender.org
Wed Oct 4 06:43:14 CEST 2017


Commit: 728cffa9ce5f7e14ca474ae9fdcb654f0e01d2b4
Author: Campbell Barton
Date:   Wed Oct 4 15:13:52 2017 +1100
Branches: master
https://developer.blender.org/rB728cffa9ce5f7e14ca474ae9fdcb654f0e01d2b4

PyAPI: fast keyword parsing for bpy.props

No functional changes.

===================================================================

M	source/blender/python/intern/bpy_props.c

===================================================================

diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 9ef8f9aa046..a46fda7ea63 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1995,8 +1995,6 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
 	BPY_PROPDEF_HEAD(BoolProperty);
 
 	if (srna) {
-		static const char *kwlist[] = {"attr", "name", "description", "default",
-		                               "options", "subtype", "update", "get", "set", NULL};
 		const char *id = NULL, *name = NULL, *description = "";
 		int id_len;
 		bool def = false;
@@ -2009,12 +2007,17 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
 		PyObject *get_cb = NULL;
 		PyObject *set_cb = NULL;
 
-		if (!PyArg_ParseTupleAndKeywords(args, kw,
-		                                 "s#|ssO&O!sOOO:BoolProperty",
-		                                 (char **)kwlist, &id, &id_len,
-		                                 &name, &description, PyC_ParseBool, &def,
-		                                 &PySet_Type, &pyopts, &pysubtype,
-		                                 &update_cb, &get_cb, &set_cb))
+		static const char *_keywords[] = {
+			"attr", "name", "description", "default",
+			"options", "subtype", "update", "get", "set", NULL,
+		};
+		static _PyArg_Parser _parser = {"s#|ssO&O!sOOO:BoolProperty", _keywords, 0};
+		if (!_PyArg_ParseTupleAndKeywordsFast(
+		        args, kw, &_parser,
+		        &id, &id_len,
+		        &name, &description, PyC_ParseBool, &def,
+		        &PySet_Type, &pyopts, &pysubtype,
+		        &update_cb, &get_cb, &set_cb))
 		{
 			return NULL;
 		}
@@ -2077,8 +2080,6 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
 	BPY_PROPDEF_HEAD(BoolVectorProperty);
 
 	if (srna) {
-		static const char *kwlist[] = {"attr", "name", "description", "default",
-		                               "options", "subtype", "size", "update", "get", "set", NULL};
 		const char *id = NULL, *name = NULL, *description = "";
 		int id_len;
 		int def[PYRNA_STACK_ARRAY] = {0};
@@ -2093,12 +2094,17 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
 		PyObject *get_cb = NULL;
 		PyObject *set_cb = NULL;
 
-		if (!PyArg_ParseTupleAndKeywords(args, kw,
-		                                 "s#|ssOO!siOOO:BoolVectorProperty",
-		                                 (char **)kwlist, &id, &id_len,
-		                                 &name, &description, &pydef,
-		                                 &PySet_Type, &pyopts, &pysubtype, &size,
-		                                 &update_cb, &get_cb, &set_cb))
+		static const char *_keywords[] = {
+			"attr", "name", "description", "default",
+			"options", "subtype", "size", "update", "get", "set", NULL,
+		};
+		static _PyArg_Parser _parser = {"s#|ssOO!siOOO:BoolVectorProperty", _keywords, 0};
+		if (!_PyArg_ParseTupleAndKeywordsFast(
+		        args, kw, &_parser,
+		        &id, &id_len,
+		        &name, &description, &pydef,
+		        &PySet_Type, &pyopts, &pysubtype, &size,
+		        &update_cb, &get_cb, &set_cb))
 		{
 			return NULL;
 		}
@@ -2181,9 +2187,6 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
 	BPY_PROPDEF_HEAD(IntProperty);
 
 	if (srna) {
-		static const char *kwlist[] = {"attr", "name", "description", "default",
-		                               "min", "max", "soft_min", "soft_max",
-		                               "step", "options", "subtype", "update", "get", "set", NULL};
 		const char *id = NULL, *name = NULL, *description = "";
 		int id_len;
 		int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0;
@@ -2196,13 +2199,19 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
 		PyObject *get_cb = NULL;
 		PyObject *set_cb = NULL;
 
-		if (!PyArg_ParseTupleAndKeywords(args, kw,
-		                                 "s#|ssiiiiiiO!sOOO:IntProperty",
-		                                 (char **)kwlist, &id, &id_len,
-		                                 &name, &description, &def,
-		                                 &min, &max, &soft_min, &soft_max,
-		                                 &step, &PySet_Type, &pyopts, &pysubtype,
-		                                 &update_cb, &get_cb, &set_cb))
+		static const char *_keywords[] = {
+			"attr", "name", "description", "default",
+			"min", "max", "soft_min", "soft_max",
+			"step", "options", "subtype", "update", "get", "set", NULL,
+		};
+		static _PyArg_Parser _parser = {"s#|ssiiiiiiO!sOOO:IntProperty", _keywords, 0};
+		if (!_PyArg_ParseTupleAndKeywordsFast(
+		        args, kw, &_parser,
+		        &id, &id_len,
+		        &name, &description, &def,
+		        &min, &max, &soft_min, &soft_max,
+		        &step, &PySet_Type, &pyopts, &pysubtype,
+		        &update_cb, &get_cb, &set_cb))
 		{
 			return NULL;
 		}
@@ -2278,9 +2287,6 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
 	BPY_PROPDEF_HEAD(IntVectorProperty);
 
 	if (srna) {
-		static const char *kwlist[] = {"attr", "name", "description", "default",
-		                               "min", "max", "soft_min", "soft_max",
-		                               "step", "options", "subtype", "size", "update", "get", "set", NULL};
 		const char *id = NULL, *name = NULL, *description = "";
 		int id_len;
 		int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1;
@@ -2296,14 +2302,20 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
 		PyObject *get_cb = NULL;
 		PyObject *set_cb = NULL;
 
-		if (!PyArg_ParseTupleAndKeywords(args, kw,
-		                                 "s#|ssOiiiiiO!siOOO:IntVectorProperty",
-		                                 (char **)kwlist, &id, &id_len,
-		                                 &name, &description, &pydef,
-		                                 &min, &max, &soft_min, &soft_max,
-		                                 &step, &PySet_Type, &pyopts,
-		                                 &pysubtype, &size,
-		                                 &update_cb, &get_cb, &set_cb))
+		static const char *_keywords[] = {
+			"attr", "name", "description", "default",
+			"min", "max", "soft_min", "soft_max",
+			"step", "options", "subtype", "size", "update", "get", "set", NULL,
+		};
+		static _PyArg_Parser _parser = {"s#|ssOiiiiiO!siOOO:IntVectorProperty", _keywords, 0};
+		if (!_PyArg_ParseTupleAndKeywordsFast(
+		        args, kw, &_parser,
+		        &id, &id_len,
+		        &name, &description, &pydef,
+		        &min, &max, &soft_min, &soft_max,
+		        &step, &PySet_Type, &pyopts,
+		        &pysubtype, &size,
+		        &update_cb, &get_cb, &set_cb))
 		{
 			return NULL;
 		}
@@ -2391,10 +2403,6 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
 	BPY_PROPDEF_HEAD(FloatProperty);
 
 	if (srna) {
-		static const char *kwlist[] = {"attr", "name", "description", "default",
-		                               "min", "max", "soft_min", "soft_max",
-		                               "step", "precision", "options", "subtype",
-		                               "unit", "update", "get", "set", NULL};
 		const char *id = NULL, *name = NULL, *description = "";
 		int id_len;
 		float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f;
@@ -2410,14 +2418,21 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
 		PyObject *get_cb = NULL;
 		PyObject *set_cb = NULL;
 
-		if (!PyArg_ParseTupleAndKeywords(args, kw,
-		                                 "s#|ssffffffiO!ssOOO:FloatProperty",
-		                                 (char **)kwlist, &id, &id_len,
-		                                 &name, &description, &def,
-		                                 &min, &max, &soft_min, &soft_max,
-		                                 &step, &precision, &PySet_Type,
-		                                 &pyopts, &pysubtype, &pyunit,
-		                                 &update_cb, &get_cb, &set_cb))
+		static const char *_keywords[] = {
+			"attr", "name", "description", "default",
+			"min", "max", "soft_min", "soft_max",
+			"step", "precision", "options", "subtype",
+			"unit", "update", "get", "set", NULL,
+		};
+		static _PyArg_Parser _parser = {"s#|ssffffffiO!ssOOO:FloatProperty", _keywords, 0};
+		if (!_PyArg_ParseTupleAndKeywordsFast(
+		        args, kw, &_parser,
+		        &id, &id_len,
+		        &name, &description, &def,
+		        &min, &max, &soft_min, &soft_max,
+		        &step, &precision, &PySet_Type,
+		        &pyopts, &pysubtype, &pyunit,
+		        &update_cb, &get_cb, &set_cb))
 		{
 			return NULL;
 		}
@@ -2502,10 +2517,6 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
 	BPY_PROPDEF_HEAD(FloatVectorProperty);
 
 	if (srna) {
-		static const char *kwlist[] = {"attr", "name", "description", "default",
-		                               "min", "max", "soft_min", "soft_max",
-		                               "step", "precision", "options", "subtype",
-		                               "unit", "size", "update", "get", "set", NULL};
 		const char *id = NULL, *name = NULL, *description = "";
 		int id_len;
 		float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3;
@@ -2523,14 +2534,21 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
 		PyObject *get_cb = NULL;
 		PyObject *set_cb = NULL;
 
-		if (!PyArg_ParseTupleAndKeywords(args, kw,
-		                                 "s#|ssOfffffiO!ssiOOO:FloatVectorProperty",
-		                                 (char **)kwlist, &id, &id_len,
-		                                 &name, &description, &pydef,
-		                                 &min, &max, &soft_min, &soft_max,
-		                                 &step, &precision, &PySet_Type,
-		                                 &pyopts, &pysubtype, &pyunit, &size,
-		                                 &update_cb, &get_cb, &set_cb))
+		static const char *_keywords[] = {
+			"attr", "name", "description", "default",
+			"min", "max", "soft_min", "soft_max",
+			"step", "precision"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list