question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: cpython.time to expose stdlib time.localtime etc

See original GitHub issue

There is a libc.time available from which I think I can patch together something equivalent to https://github.com/python/cpython/blob/master/Modules/timemodule.c#L490, but itd be nice to have a canonical version exposed directly.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
scodercommented, Mar 30, 2021

Yeah, apparently, it’s a GNU specific extension. The usual way we deal with those is to add them to the struct if it’s reasonable, because it doesn’t normally hurt to let Cython think they are there as long as users don’t write time into their code. But struct-dict conversion makes this … annoying.

In this case, I would remove the fields. We can add them in some other .pxd file if someone wants them. Does that sound reasonable?

0reactions
da-woodscommented, Mar 31, 2021

There isn’t currently a mechanism to say “copy this field only if it exists on this platform”.

It would be possible to implement this mechanism in the struct-to-dict converter functions in C++11. I’m not really convinced it’s a good idea to have the behaviour vary so much depending on the compiler, but it could be done if there was a real use for it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

time — Time access and conversions — Python 3.11.1 ...
This module provides various time-related functions. ... The time value as returned by gmtime() , localtime() , and strptime() , and accepted by...
Read more >
Python | time.localtime() method - GeeksforGeeks
This module comes under Python's standard utility modules. time.localtime() method of Time module is used to convert a time expressed in seconds ...
Read more >
Python time-zone handling - LWN.net
to elapsed time (86400 SI seconds) is nuts will inevitably result in subtle errors. Add a civil day to an abstract date?
Read more >
A Beginner's Guide to the Python time Module
In this tutorial, you'll learn how to use the Python time module to represent dates and times in your application, manage code execution, ......
Read more >
datetime needs an "epoch" method #46988 - python/cpython
Changing time.mktime doesn't seems an option, so the best alternative is to implement a method in datetime type. Is there a real demand...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found