GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace is_temporal checks with Cython version by WillAyd · Pull Request #55506 · pandas-dev/pandas

Conversation

@WillAyd

@WillAyd WillAyd commented Oct 13, 2023

Copy link
Copy Markdown
Member

With Cython 3.0.3 I was unable to build pandas. Looks like is_timedelta / is_datetime functions were getting mixed between static / non-static declarations. I wasn't sure why that was happening, but while investigating noted that these got ported upstream by @jbrockmendel a few years back, so I think it makes sense to leverage that instead (also clears the issue)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@WillAyd
Replace is_temporal checks with Cython version
b106045
@WillAyd
WillAyd requested a review from MarcoGorelli as a code owner October 13, 2023 13:01
WillAyd
WillAyd commented Oct 13, 2023
View reviewed changes
Comment thread pandas/_libs/tslibs/util.pxd
# --------------------------------------------------------------------
# Type Checking

cdef inline bint is_integer_object(object obj) noexcept nogil:

@WillAyd WillAyd Oct 13, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We previously declared is_timedelta64_object / is_datetime64_object to be nogil, which cascaded through the rest of the functions in this pxd file. However, the upstream function is not considered nogil, with some discussion coming back to here:

numpy/numpy#16266 (comment)

I think its a mistake for any of the functions in this module that touch CPython objects to be declared nogil, unless something more recent in CPython has declared these functions as such (haven't looked)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jbrockmendel jbrockmendel Oct 13, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

can we just rip this out since we're using the cnp version everywhere?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jbrockmendel jbrockmendel Oct 13, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

oh never mind, i see you did that where relevant below

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@WillAyd WillAyd Oct 13, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You are talking about the nogil right? Yea I did the minimum required for this PR. There are still other functions in util.pxd where it should probably be removed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jbrockmendel

jbrockmendel commented Oct 13, 2023

Copy link
Copy Markdown
Member

Does this affect our minimum cython/numpy versions? (IIRC cython has a numpy/__init__.pxd file that got used sometimes and they wanted to get rid of it but i dont know if that ever happened or what versions are affected)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mroeschke mroeschke added the Internals Related to non-user accessible pandas implementation label Oct 13, 2023
@mroeschke

mroeschke commented Oct 13, 2023

Copy link
Copy Markdown
Member

Would this allow us to unpin our Cython <3.0.3 in our CI files?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbrockmendel

jbrockmendel commented Oct 13, 2023

Copy link
Copy Markdown
Member

As long as you're doing these, might as well change to use the other stuff upstreamed into numpy in numpy/numpy#16266?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@WillAyd

WillAyd commented Oct 13, 2023

Copy link
Copy Markdown
Member Author

Would this allow us to unpin our Cython <3.0.3 in our CI files?

Ah didn't realize we pinned that. I believe so; at least locally I can build the entire code base with this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@WillAyd

WillAyd commented Oct 13, 2023

Copy link
Copy Markdown
Member Author

As long as you're doing these, might as well change to use the other stuff upstreamed into numpy in numpy/numpy#16266?

Unfortunately there is a problem where the definition we have of NPY_DATETIMEUNIT in pandas._libs.tslibs.np_datetime differs from what Cython offers, the main difference being the Cython version does not offer NPY_FR_GENERIC as a value. Our code does some comparison to that value, so we can't swap over to using get_datetime64_unit because Cython/C will not be happy with the difference in those enum declarations

I think that's a bug in Cython - the source file numpy/ndarraytypes.h does have an enum member for NPY_FR_GENERIC so probably just needs to be upstreamed in Cython before we can fully implement your PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@WillAyd

WillAyd commented Oct 13, 2023

Copy link
Copy Markdown
Member Author

@jbrockmendel see also https://github.com/cython/cython/pull/5765/files

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lithomas1

lithomas1 commented Oct 14, 2023

Copy link
Copy Markdown
Contributor

With Cython 3.0.3 I was unable to build pandas. Looks like is_timedelta / is_datetime functions were getting mixed between static / non-static declarations. I wasn't sure why that was happening, but while investigating noted that these got ported upstream by @jbrockmendel a few years back, so I think it makes sense to leverage that instead (also clears the issue)

This was a bug in Cython, but I'm happy to see that this fixes it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@WillAyd

WillAyd commented Oct 17, 2023

Copy link
Copy Markdown
Member Author

OK I updated the enum definition upstream in numpy/numpy#24923 (comment) so can come back around for the rest of these when that goes through. Any concern with this PR in its current state?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mroeschke

mroeschke commented Oct 18, 2023

Copy link
Copy Markdown
Member

I'm OK with the fix. Could you also unpin Cython 3.0.3 in our files?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lithomas1

lithomas1 commented Oct 18, 2023

Copy link
Copy Markdown
Contributor

#55582.

I think we can unpin generally anyways since Cython 3.0.4 is out.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lithomas1
lithomas1 approved these changes Oct 18, 2023
View reviewed changes
@lithomas1 lithomas1 added this to the 2.2 milestone Oct 18, 2023
@WillAyd
Merge branch 'main' into ts-func-cleanups
4ed4b88
mroeschke
mroeschke approved these changes Oct 19, 2023
View reviewed changes
@mroeschke
mroeschke merged commit ca39324 into pandas-dev:main Oct 19, 2023
@mroeschke

mroeschke commented Oct 19, 2023

Copy link
Copy Markdown
Member

Thanks @WillAyd

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbrockmendel

jbrockmendel commented Oct 19, 2023

Copy link
Copy Markdown
Member

nice!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@jbrockmendel jbrockmendel jbrockmendel left review comments
@mroeschke mroeschke mroeschke approved these changes
@MarcoGorelli MarcoGorelli Awaiting requested review from MarcoGorelli
+1 more reviewer
@lithomas1 lithomas1 lithomas1 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Internals Related to non-user accessible pandas implementation

Projects

None yet

Milestone

2.2

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@WillAyd @jbrockmendel @mroeschke @lithomas1
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.