pybind / pybind/pybind11

Conversion between std::chrono and numpy.datetime64

Open
#2,078 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Using #include <pybind11/chrono.h> we can define

def(py::init([](const std::chrono::system_clock::time_point& obj)

so that we can convert between std::chrono and python's datetime.

Is there a similar concept for conversions between std::chrono and numpy's datetime64? I had a look at pybind11/numpy.h but couldn't find anything.

I am happy implement it and submit a PR, if someone could point me in the right direction for how to do it. Many thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the existing conversion approach in pybind11/chrono.h with the NumPy-related facilities in pybind11/numpy.h. Determine the expected conversion behavior between std::chrono and numpy.datetime64, then confirm that the resulting implementation supports the requested conversion in the relevant binding definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, numpy, python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.