Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PICARD-1379: Fix PyUnicode_GetSize deprecation warning in astrcmp #1008

Closed

Conversation

phw
Copy link
Member

@phw phw commented Oct 18, 2018

Summary

Use PyUnicode_GetLength instead of deprecated PyUnicode_GetSize. Requires Python >= 3.3, but we list Python 3.5 as the minimum anyway.

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • Describe this change in 1-2 sentences:

Problem

Solution

Action

Use PyUnicode_GetLength instead of deprecated PyUnicode_GetSize. Requires Python >= 3.3
@@ -156,8 +156,8 @@ astrcmp(PyObject *self, PyObject *args)

us1 = PyUnicode_AS_UNICODE(s1);
us2 = PyUnicode_AS_UNICODE(s2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed it is. There was just no warning output, probably because these are macros. I will update the PR

@phw
Copy link
Member Author

phw commented Oct 18, 2018

I updated the module for the new Unicode API. For a quick speed comparison I measured running the unit test function 1 million times. On my system:

  • Old implementation: 3.9155 seconds
  • New implementation: 4.0373 seconds
  • New implementation without 6eb132b: 4.5491

So a slight performance decrease of 3%. But for comparison the Python implementation takes roughly 186 seconds for the same call count.

@phw phw force-pushed the PICARD-1379-fix-astrcmp-deprecation-warnings branch from 652d40c to 03758c0 Compare October 18, 2018 20:32
@phw phw closed this Oct 18, 2018
@phw
Copy link
Member Author

phw commented Oct 18, 2018

Sorry, this needs more work. I just realized my patch breaks the threading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants