Skip to content

[CLN] Replace np_datetime code with numpy versions #21852

Closed
@jbrockmendel

Description

@jbrockmendel

@jreback we discussed this briefly, hopefully you'll have better luck with it than me.

pandas/_libs/src/datetime/np_datetime.c and np_datetime_strings.c share a ton of code with numpy:

https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/datetime.c
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/_datetime.h
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/datetime_strings.c
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/datetime_strings.h

My attempts so far to "get at" these numpy functions via #include have failed, someone with stronger C-fu than me will have to try. The testing ground I've been trying on is src/ujson/python/objToJSON.c since all of the np_datetime functions it uses have drop-in counterparts in numpy:

PANDAS_DATETIMEUNIT --> NPY_DATETIMEUNIT
PANDAS_FR_ns --> NPY_FR_ns (ditto s, ms, us)
pandas_datetimestruct --> npy_datetimestruct

get_datetime_iso_8601_strlen --> identical

make_iso_8601_datetime has fewer args in the pandas version, largely since we removed unnecessary ones a few months ago. Adding hard-coded args in should make them equivalent.

convert_pydatetime_to_datetimestruct also looks like dummy arguments need to be re-introduced to make them identical.

convert_datetime_to_datetimestruct has a different first-argument (again one we simplified) but is functionally identical.
convert_datetimestruct_to_datetime ditto.

parse_iso_8601_datetime has non-trivial differences IIRC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CleanDependenciesRequired and optional dependencies

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions