Issue 9183: Intern UTC timezone (original) (raw)
Attached patch makes timezone(timedelta(0)) always return the same instance as timezone.utc. See for pure python implementation.
With this patch, manipulation of aware datetime objects will be as efficient as that of naive datetime objects. Note that having timezone.utc is not enough to assure that the same tzinfo object is used because aware objects can be produced by datetime.strptime(). With this patch,
datetime.strptime('2010-07-06 21:39:55 +0000', "%Y-%m-%d %H:%M:%S %z").tzinfo is timezone.utc True