[ https://issues.apache.org/jira/browse/ARROW-2354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16414151#comment-16414151 ]
ASF GitHub Bot commented on ARROW-2354: --------------------------------------- cpcloud commented on a change in pull request #1794: ARROW-2354: [C++] Make PyDecimal_Check() faster URL: https://github.com/apache/arrow/pull/1794#discussion_r177166321 ########## File path: cpp/src/arrow/python/helpers.cc ########## @@ -227,12 +227,16 @@ Status UInt64FromPythonInt(PyObject* obj, uint64_t* out) { } bool PyDecimal_Check(PyObject* obj) { - // TODO(phillipc): Is this expensive? - OwnedRef Decimal; - Status status = ImportDecimalType(&Decimal); - DCHECK_OK(status); - const int32_t result = PyObject_IsInstance(obj, Decimal.obj()); - DCHECK_NE(result, -1) << " error during PyObject_IsInstance check"; + static OwnedRef decimal_type; + if (!decimal_type.obj()) { + Status status = ImportDecimalType(&decimal_type); + DCHECK_OK(status); + DCHECK(PyType_Check(decimal_type.obj())); + } + // PyObject_IsInstance() is slower as it has to check for virtual subclasses Review comment: This was the cause of the performance regression, and not importing over and over? Or was it both? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [C++] PyDecimal_Check() is much too slow > ---------------------------------------- > > Key: ARROW-2354 > URL: https://issues.apache.org/jira/browse/ARROW-2354 > Project: Apache Arrow > Issue Type: Bug > Components: C++, Python > Affects Versions: 0.9.0 > Reporter: Antoine Pitrou > Assignee: Antoine Pitrou > Priority: Major > Labels: pull-request-available > > See https://github.com/apache/arrow/issues/1792 -- This message was sent by Atlassian JIRA (v7.6.3#76005)