Comments (3)
I was able to improve this slightly by patching the timezone
function and caching the Timezone
objects but it is still very slow and demands a lot of cpu.
from pendulum.
more investigation shows that this call to convert
on this line specifically with the dt.astimezone(self)
, which appears to be a builtin function, however like I stated above using the call to astimezone
directly takes almost nothing. That makes this all the more perplexing.
from pendulum.
This must indeed be an inadvertent regression—the pendulum FAQ shows pendulum's performance was way faster than arrow
, but now it seems reversed:
...........
tz change (pendulum): Mean +- std dev: 58.0 us +- 0.6 us
...........
tz change (stdlib): Mean +- std dev: 233 ns +- 2 ns
...........
tz change (arrow): Mean +- std dev: 4.67 us +- 0.06 us
benchmark source:
import pyperf
runner = pyperf.Runner()
runner.timeit(
"tz change (pendulum)",
"dt.in_tz('America/New_York')",
setup="from pendulum import datetime; dt = datetime(2020, 3, 20, 12, 30, 45, tz='Europe/Amsterdam')",
)
runner.timeit(
"tz change (stdlib)",
"dt.astimezone(target)",
setup="from datetime import datetime; from zoneinfo import ZoneInfo; "
"dt = datetime(2020, 3, 20, 12, 30, 45, tzinfo=ZoneInfo('Europe/Amsterdam')); "
"target = ZoneInfo('America/New_York')",
)
runner.timeit(
"tz change (arrow)",
"dt.to('America/New_York')",
setup="import arrow; dt = arrow.get(2020, 3, 20, 12, 30, 45, 0, tz='Europe/Amsterdam'); "
)
from pendulum.
Related Issues (20)
- Bug / regression: Unable to parse string '031' with 'DDDD' format using Pendulum 3.0.0
- Regression - Inconsistent DBAPI serialization of pendulum datetimes
- Duration division, multiplication and mod broken for month lengths. HOT 1
- Default datetime string format changed in 3.0 release HOT 2
- Security issue or bug with pipenv ? HOT 1
- to_iso8601_string
- instance() fails for datetimes with pytz.FixedOffsets
- "import pendulum" causes unwanted import of pytest (presence of pytest in sys.modules often used to control Python behaviour) HOT 1
- MMM is not case-insensitive like Java
- If you have the /etc/timezone file set to a timezone string, pendulum.UTC has that timezone's utcoffset instead of None HOT 1
- in_words() exclude week
- timedelta additions to pendulum.DateTime HOT 1
- Day of week constants
- pendulum.instance & dateutil.tz compatibility
- Localized Format LT inconsistent with leading zeroes
- Default string representation is not iso anymore HOT 1
- Add DateTime to typing for diff()
- Cannot install version 2.x via pip because of dead link for get-poetry.py in build-wheels.sh HOT 1
- IsADirectoryError in datetime.py
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pendulum.