First call to pytz.timezone is slow in virtualenv

Viewed 1424

I have installed pytz (v2013.8, but it happens in 2013.b, 2011k) in a virtualenv. The first call to

pytz.timezone("US/Eastern")

takes about 4 seconds. In a regular environment this is essentially instantaneous.

Does anyone have a trick to get this to run faster?

4 Answers

You can actually specify the location of zoneinfo by setting the environment variable PYTZ_TZDATADIR:

export PYTZ_TZDATADIR=/usr/share/zoneinfo

The compressed zoneinfo files are read only if PYTZ_TZDATADIR is not set.

Related