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

Do not add import bounds #29

Open
orlp opened this issue May 18, 2024 · 0 comments
Open

Do not add import bounds #29

orlp opened this issue May 18, 2024 · 0 comments

Comments

@orlp
Copy link

orlp commented May 18, 2024

The pyo3_built macro adds an import bound for email.utils to parse a string date into a datetime, which seems really unnecessary to me. It adds a significant amount of import time to our library.

    ($py: ident, $info: ident, $dict: ident, "time") => {
        let dt = $py
            .import_bound("email.utils")?
            .call_method1("parsedate_to_datetime", ($info::BUILT_TIME_UTC,))?;
        $dict.set_item("info-time", dt)?;
    };

Even parsing the date in Rust and importing datetime to generate a Datetime object directly (while significantly better) seems unnecessary, although that would be a backwards-compatible.

My suggestion would be to replace the info-time field with a ISO 8601 timestamp string that we generate on the Rust side. Then if a user really wants a Datetime they can just datetime.datetime.fromisoformat the string.

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

No branches or pull requests

1 participant