Path: csiph.com!news.swapon.de!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'cache': 0.05; 'implements': 0.07; 'pypy': 0.07; 'api': 0.09; 'cc:addr:python-list': 0.09; 'merged': 0.09; 'objects.': 0.09; 'python': 0.10; 'applies': 0.15; 'instead.': 0.15; 'caching': 0.16; 'did,': 0.16; 'did.': 0.16; 'utc': 0.16; ';-)': 0.18; 'subject:] ': 0.19; 'changes': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**2': 0.20; 'subject:skip:i 10': 0.22; 'implemented': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'define': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'this.': 0.28; 'values': 0.28; 'cases.': 0.29; 'hash': 0.29; 'promising': 0.29; 'objects': 0.29; 'expensive': 0.32; 'getting': 0.33; 'problem': 0.33; 'similar': 0.33; 'that,': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'depends': 0.36; 'subject:" ': 0.36; 'subject:?': 0.36; 'being': 0.37; 'expect': 0.37; 'turn': 0.37; 'subject:-': 0.39; 'care': 0.60; 'is.': 0.63; 'more': 0.63; 'our': 0.64; 'benefit': 0.66; 'subject:there': 0.66; '495': 0.84; 'measurable': 0.84; 'received :mail-ob0-x22d.google.com': 0.84; 'subject:any': 0.84; 'wash': 0.84; 'improvement': 0.93; 'subject:Are': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=r13LCEUaFSq/0YlLesjhv22CnkY/zlIfdqF3v10Q4LU=; b=HHTjKij6pF3aj0yK0akxZBC4fziDO9GazyseZ8k4JHiidHTwg26vIWU3e0QcCA3JLm DvLzzenwIl1evrgSW+F6hx5chgtLTqQOor8JHvrC8BKtp4DV5m08WRK/jCwtSvXGfE/l BdaXPxWXW7UcLW6U2sn+aSnovBP2Qi9aTUL46g73Gd6huDfRkHfWeXrtrCaLcaZi3bn4 wPdnCFCdpXDdXcNrl7Ncj1uNEx8Fm1B+gHIWJQnwOEHJzONm29IJqgC1SAopyUzMLO/+ hxdVzGJSgaz3Ju2te60PYbCWy2WLaRTcWn7r0AFR68iO8IG51+/D4G1omisxwUEhG67L CACw== X-Received: by 10.182.168.114 with SMTP id zv18mr13293812obb.84.1442260208263; Mon, 14 Sep 2015 12:50:08 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1442085362.324875.381920729.5E7A6DCE@webmail.messagingengine.com> <201509131224.t8DCOXHO004891@fido.openend.se> <201509131600.t8DG07e0025688@fido.openend.se> <201509132031.t8DKVTwJ028027@fido.openend.se> <201509140827.t8E8RPqb001076@fido.openend.se> <1442257996.253100.383441705.7A0986C7@webmail.messagingengine.com> From: Tim Peters Date: Mon, 14 Sep 2015 14:49:53 -0500 Subject: Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo? To: Alexander Belopolsky Cc: Random832 , Python-List , datetime-sig Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442260211 news.xs4all.nl 23807 [2001:888:2000:d::a6]:56951 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96595 [Tim] >> It would be nice to have! .utcoffset() is an expensive operation >> as-is, and being able to rely on tm_gmtoff would make that dirt-cheap >> instead. [Alex] > If it is just a question of optimization, Yes. If it's more than just that, then 495 doesn't actually solve the problem of getting the correct UTC offset in all cases. > datetime objects can be extended to cache utcoffset. Note that PyPy > have recently added caching of the hash values in datetime objects. I > merged their changes in our datetime.py, but it did not look like C > implementation would benefit from it as much as pure python did. I > expect something similar from caching utcoffset: a measurable > improvement for tzinfos implemented in Python and a wash for those > implemented in C. (A more promising optimization approach is to define a C > API for tzinfo interface.) There's no answer to this. It depends on how expensive .utcoffset() is, which in turn depends on how the tzinfo author implements it. I don't care now fast it is. But, even if I did, "premature optimization" applies at this time ;-)