Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68528

Re: Controlling buffer alignment in file.read()

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'alignment': 0.07; 'binary': 0.07; 'method.': 0.07; 'subject:()': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'aligned.': 0.16; 'allocates': 0.16; 'arbitrary.': 0.16; 'file.read()': 0.16; 'multiples': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'all,': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; 'aligned': 0.31; "user's": 0.31; 'file': 0.32; 'device': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'method': 0.36; 'url:org': 0.36; 'project': 0.37; 'issue': 0.38; 'pm,': 0.38; 'does': 0.39; 'read': 0.60; 'therefore,': 0.64; 'mar': 0.68; 'covers': 0.68
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=zHX1oAU0sUFeHY1Uti4acHa11+dgGqCxEb45jO1BtII=; b=B3ueI69aVTh/Jf+ZE9zr0RITMyCNyOvptJWGJ5AFTXoXpJUhJlBfKYwUi9FfvLdKnv JrtUypxZzOYmw9daZl7lfIK4kg/VlNDskJsg7klcQieiivR4axg43nwoGoYYM6F73uHi 2afidyegRigpCj7gMqA84RFQmwKBKF+2fH7lR0o8yHbBIPlrFi1kT5QBZb04E5qUBMzo CI9ScFj/3wAhUhwOS6vLP0mAjmom216US7CyUPblvQ6V7Zv50TSGFB8KWbm+0eQU499N att2Knp3am3K6mG8V/piDyRwj1hZLtsdVuP76wLHiveccwU2LZ3cAuAST2zGt/mmCs8A t/gw==
MIME-Version 1.0
X-Received by 10.236.75.74 with SMTP id y50mr47298322yhd.27.1395190920132; Tue, 18 Mar 2014 18:02:00 -0700 (PDT)
In-Reply-To <F5ED8E150D0FF14F82CAF3C46756763232396ECB@FMSMSX104.amr.corp.intel.com>
References <F5ED8E150D0FF14F82CAF3C46756763232396ECB@FMSMSX104.amr.corp.intel.com>
Date Tue, 18 Mar 2014 18:01:59 -0700
Subject Re: Controlling buffer alignment in file.read()
From Dan Stromberg <drsalists@gmail.com>
To "Haralanov, Mitko" <mitko.haralanov@intel.com>
Content-Type text/plain; charset=ISO-8859-1
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8266.1395190928.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1395190928 news.xs4all.nl 2903 [2001:888:2000:d::a6]:52892
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68528

Show key headers only | View raw


On Tue, Mar 18, 2014 at 1:23 PM, Haralanov, Mitko
<mitko.haralanov@intel.com> wrote:
> 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 function 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?

This is a lot like what my odirect project does:
http://stromberg.dnsalias.org/~strombrg/odirect/

It does buffer alignment, because O_DIRECT requires buffer alignment.
It's a Python-callable SWIG wrapper for some C code.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Controlling buffer alignment in file.read() Dan Stromberg <drsalists@gmail.com> - 2014-03-18 18:01 -0700

csiph-web