Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'alignment': 0.07; 'binary': 0.07; 'method.': 0.07; 'subject:()': 0.09; 'python': 0.11; 'aligned.': 0.16; 'allocates': 0.16; 'arbitrary.': 0.16; 'file.read()': 0.16; 'multiples': 0.16; 'thanks,': 0.17; 'all,': 0.19; 'to:name:python-list@python.org': 0.22; 'function': 0.29; 'aligned': 0.31; "user's": 0.31; 'file': 0.32; 'received:169.254': 0.32; 'device': 0.34; 'there': 0.35; 'method': 0.36; 'charset:us- ascii': 0.36; 'received:169': 0.37; 'received:10': 0.37; 'to:addr :python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'therefore,': 0.64; 'covers': 0.68 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,680,1389772800"; d="scan'208";a="501464236" From: "Haralanov, Mitko" To: "python-list@python.org" Subject: Controlling buffer alignment in file.read() Thread-Topic: Controlling buffer alignment in file.read() Thread-Index: Ac9C5+Y0EIEp9ebFTROzTNrUEcEfyw== Date: Tue, 18 Mar 2014 20:23:19 +0000 Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.1.200.107] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395174272 news.xs4all.nl 2845 [2001:888:2000:d::a6]:36105 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68516 Hi all, I am using Python to read from a binary device file which requires that all= read sizes are in 8byte multiples and the user's buffer is 8byte aligned. I am currently using a file object and the file.read() method. However, the= issue is that the file.read() method allocates the buffer passed to C func= tion under the covers and, therefore, the alignment is arbitrary. Is there a way that I can get file.read() to use an 8byte aligned buffer? Thanks, - Mitko