Description
PySide and Shiboken make a lot of use of Python strings. The simple way to use Python strings is for instance
PyObject *attr = PyObject_GetAttrString(obj, "sys"); PyObject *attr = PyObject_GetAttrString(obj, "__module__");
We give an alternative implementation instead, that lets you write
PyObject *attr = PyObject_GetAttr(obj, PyName::sys()); PyObject *attr = PyObject_GetAttr(obj, PyMagicName::module());
This solution works without any macros and uses the namespace feature as a benefit.
The solution is no longer a prototype and implements the feature for all ...String() functions, including the generated source code. The necessary string functions are half-automatically generated by running tools/scrape-names.py. There are 1580 generated static string functions at the moment.
Attachments
For Gerrit Dashboard: PYSIDE-1087 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
272931,17 | WIP: Speed: Avoid some repeated string constant initialization | 5.14 | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
274699,3 | Clean up string related macros | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
275029,4 | libpyside: Use new static strings | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
275030,6 | Speed: Avoid some repeated string constant initialization | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
275599,3 | patch_tp_new_wrapper(): Add an assert for the "__new__" entry | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |