Skip to content

Conversation

@trimbo
Copy link
Contributor

@trimbo trimbo commented Aug 26, 2019

_baked.c was the most complicated one. Py3 Unicode implementation
requires initialization. I left the Python 2 implementation alone
because I'm not entirely sure of the overhead being saved with memcpy
right now.

_baked.c was the most complicated one. Py3 Unicode implementation
requires initialization. I left the Python 2 implementation alone
because I'm not entirely sure of the overhead being saved with memcpy
right now.
@trimbo trimbo requested a review from nicksay August 26, 2019 18:59
@trimbo
Copy link
Contributor Author

trimbo commented Aug 26, 2019

No detected performance regression with this.

New:

Spitfire template 9.65 ms
Spitfire template -O1 8.18 ms
Spitfire template -O2 5.70 ms
Spitfire template -O3 5.74 ms
Spitfire template baked 11.02 ms
Spitfire template baked -O1 6.79 ms
Spitfire template baked -O2 6.86 ms
Spitfire template baked -O3 6.90 ms
Spitfire template unfiltered 5.71 ms
Spitfire template unfiltered -O1 2.19 ms
Spitfire template unfiltered -O2 2.16 ms
Spitfire template unfiltered -O3 2.11 ms

Old:

Spitfire template 9.84 ms
Spitfire template -O1 8.37 ms
Spitfire template -O2 5.97 ms
Spitfire template -O3 5.83 ms
Spitfire template baked 10.97 ms
Spitfire template baked -O1 6.95 ms
Spitfire template baked -O2 6.85 ms
Spitfire template baked -O3 6.94 ms
Spitfire template unfiltered 5.74 ms
Spitfire template unfiltered -O1 2.16 ms
Spitfire template unfiltered -O2 2.18 ms
Spitfire template unfiltered -O3 2.13 ms

Py_INCREF(value);
return value;
}
PyObject *args = Py_BuildValue("(N)", value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment on why you are choosing N (and therefore not incrementing the reference count) instead of O?

static PyTypeObject SanitizedPlaceholderType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL,0 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PyVarObject_HEAD_INIT(NULL,0 )
PyVarObject_HEAD_INIT(NULL, 0)

0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
&PyUnicode_Type, /* tp_base */
Copy link
Contributor

@nicksay nicksay Aug 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're conditionally setting tp_base below, let's not set it here too

Suggested change
&PyUnicode_Type, /* tp_base */
0, /* tp_base */

}

if (!(PyUnicode_Check(name) || PyString_Check(name))) {
if (!(PyUnicode_Check(name) || PyBytes_Check(name))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to either include bytesobject.h for python2.6+ compatibility of PyBytes_Check or add a PY_MAJOR_VERSION check here like you do elsewhere

}

if (!(PyUnicode_Check(name) || PyString_Check(name))) {
if (!(PyUnicode_Check(name) || PyBytes_Check(name))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to either include bytesobject.h for python2.6+ compatibility of PyBytes_Check or add a PY_MAJOR_VERSION check here like you do elsewhere

Copy link
Contributor

@nicksay nicksay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of changes, I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants