Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 47035431FD0 for ; Mon, 20 Jun 2011 09:53:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d7nUxEY62Oth for ; Mon, 20 Jun 2011 09:53:39 -0700 (PDT) Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU [18.7.68.35]) by olra.theworths.org (Postfix) with ESMTP id CB431431FB6 for ; Mon, 20 Jun 2011 09:53:39 -0700 (PDT) X-AuditID: 12074423-b7ce8ae000000a29-2e-4dff7b0c300e Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id BA.11.02601.C0B7FFD4; Mon, 20 Jun 2011 12:53:32 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p5KGrcZt010422; Mon, 20 Jun 2011 12:53:39 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p5KGrbiW018893 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 20 Jun 2011 12:53:38 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72) (envelope-from ) id 1QYhj7-0000zr-Bm; Mon, 20 Jun 2011 12:53:29 -0400 Date: Mon, 20 Jun 2011 12:53:29 -0400 From: Austin Clements To: Sebastian Spaeth Subject: Re: [python] segfaults at Message.get_date Message-ID: <20110620165329.GN16025@mit.edu> References: <20110616215439.GA26997@brick> <87boxxq833.fsf@SSpaeth.de> <20110617161024.GA8154@optimusprime> <87hb7n300m.fsf@SSpaeth.de> <87hb7m5f4s.fsf@gmail.com> <878vsxvu3x.fsf@SSpaeth.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878vsxvu3x.fsf@SSpaeth.de> User-Agent: Mutt/1.5.20 (2009-06-14) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplleLIzCtJLcpLzFFi42IRYrdT0eWp/u9rsKBNzOL6zZnMFrPmzGN0 YPJ4tuoWs8fiL0tZApiiuGxSUnMyy1KL9O0SuDImf9vOVrCAt+Lco49MDYy3uboYOTkkBEwk ft6azwhhi0lcuLeerYuRi0NIYB+jxMz1O6GcDYwSazfuZoVwTjJJXLt7jRnCWcIocXzWJnaQ fhYBVYl5Px4wg9hsAhoS2/YvB5srIqAtcbRlByuIzSwgLfHtdzMTiC0sYCyxedFxsF5eAR2J 1jaY3f8ZJZZPvcsMkRCUODnzCQtEs5bEjX8vgZo5wAYt/8cBEuYE2vVr4wGwmaICKhLX9rez TWAUmoWkexaS7lkI3QsYmVcxyqbkVunmJmbmFKcm6xYnJ+blpRbpmunlZpbopaaUbmIEh7aL 8g7GPweVDjEKcDAq8fA+Kv/vK8SaWFZcmXuIUZKDSUmUd18lUIgvKT+lMiOxOCO+qDQntfgQ owQHs5IIb/zjf75CvCmJlVWpRfkwKWkOFiVx3lxvoDaB9MSS1OzU1ILUIpisDAeHkgTv3xKg rGBRanpqRVpmTglCmomDE2Q4D9BwS5DFvMUFibnFmekQ+VOMilLivF5VIKNBEhmleXC9sNTz ilEc6BVh3iSQKh5g2oLrfgU0mAlo8P9XIFcXlyQipKQaGJdkLXoW2qh8YkIRu2WeT1Blp07q +npt+69914K1CvJnVu+59LklMDg38hNHiZzIyrkhyl9XhJzZdPW0StR6nRvLOv/lGmxyutWw l19oTUrf6uydNfdsVmxRnGhsOPNBwFb/GPfbvntXVmwx+XWt0DaA117mZgXr7N3cFsmahy7M /6e43yt+sRJLcUaioRZzUXEiAGnONK8YAwAA Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2011 16:53:40 -0000 Quoth Sebastian Spaeth on Jun 20 at 9:29 am: > On Sun, 19 Jun 2011 19:51:11 -0400, Austin Clements wrote: > > A double will precisely represent integers up to 2^53, so this > > conversion shouldn't be a problem until the year 285422109 or so. > > But given that it works, is it actually necessary, that xapian > apparently pulls an int from the database, returns a std::string to > libnotmuch, which calls a helper function to unserialize it to a double > and casts it to time_t before handing it to the user how probably uses > it as a long? > > Can't we easily put in longs and get longs back? Xapian only knows about strings, so there has to be serialization somewhere and the serialized form has to have the same collation order as the numerical order of the original numbers. You could do this by storing the bytes of the long in big-endian form, but that's basically what sortable_serialise does: roughly, the first byte stores the number of bits needed to represent the number, followed by enough bytes to hold those bits in big-endian. Since POSIX permits a wide range of types to implement time_t, sortable_serialise also has the major advantage that it can handle any of them. So, taking portability and time_t as assumptions, there are no unnecessary conversion steps here (and, really, it's just string->double->time_t on Linux and just string->time_t on a platform that uses floating point time_t's). Alternatively, notmuch could switch to using long instead of time_t for dates, but that seems like a lot of effort for little gain and results in portability friction whenever notmuch wants to use the standard C time API's.