Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've been working on a Python library that uses a C extension module to do ISO 8601 parsing.

Part of that work requires the creation of tzinfo objects, which is by far the slowest part of the parse. Calls out to Python implementations of tzinfo (currently pytz.FixedOffset) are simply too slow.

In Python 3.7, datetime.timezone is finally exposed to the C-API. My code takes adavantage of it, and gets a tremendous performance boost from using a C implementation instead of a Python one. I'd love to find a similar C implementation that I could use for Python < 3.6. Perhaps a "backport" of 3.7's datetime.timezone?

I've seen many Python implementations of tzinfo (pytz, datetuil.tz, django.utils.timezone, psycopg2.tz) but none in C.

Are there C implementations of tzinfo (besides datetime.timezone)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
316 views
Welcome To Ask or Share your Answers For Others

1 Answer

After searching some more, I ended up finding an implementation in Pendulum's low level ISO 8601 parser.

Edit: This implementation was eventually used in my backport of datetime.fromisoformat


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...