Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Atomic file.get(offset, length)

Received: by 10.180.98.234 with SMTP id el10mr4304120wib.3.1342998911264;
        Sun, 22 Jul 2012 16:15:11 -0700 (PDT)
X-BeenThere: python-ideas@googlegroups.com
Received: by 10.216.228.99 with SMTP id e77ls4035214weq.9.gmail; Sun, 22 Jul
 2012 16:15:11 -0700 (PDT)
Received: by 10.180.95.2 with SMTP id dg2mr4316602wib.2.1342998911110;
        Sun, 22 Jul 2012 16:15:11 -0700 (PDT)
Received: by 10.180.95.2 with SMTP id dg2mr4316601wib.2.1342998911096;
        Sun, 22 Jul 2012 16:15:11 -0700 (PDT)
Return-Path: <python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org>
Received: from mail.python.org (mail.python.org. [82.94.164.166])
        by gmr-mx.google.com with ESMTPS id i17si1955257wiw.0.2012.07.22.16.15.11
        (version=TLSv1/SSLv3 cipher=OTHER);
        Sun, 22 Jul 2012 16:15:11 -0700 (PDT)
Received-SPF: pass (google.com: domain of python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org designates 82.94.164.166 as permitted sender) client-ip=82.94.164.166;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org designates 82.94.164.166 as permitted sender) smtp.mail=python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org; dkim=pass header...@python.org
Received: from albatross.python.org (localhost [127.0.0.1])
	by mail.python.org (Postfix) with ESMTP id 3WgMB645NqzPXJ
	for <python-ideas-garchive-35620@googlegroups.com>; Mon, 23 Jul 2012 01:15:10 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=python.org; s=200901;
	t=1342998910; bh=+DkLnxwJh2/bH+C629zYJ/CLpZwj8XkAY+I/0dl5S9Y=;
	h=Date:From:To:Message-ID:MIME-Version:In-Reply-To:References:Cc:
	 Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:
	 List-Subscribe:Content-Type:Content-Transfer-Encoding:Sender;
	b=t3Pu4NSY1ujlClBoQtSI0x4JxkVo8GGTqfbGnTzjMrTN9lW+4ryUPlGhmmJ4w65AH
	 GJ6nBDTHWWNGigijbEeogngowDemvUohLAv0UNyupvlYSiAGbbOHVT3srzKR9xeVQm
	 7gEabzPodgiQ/qreLIcHMBL3DPQqERA2CqkTmjVQ=
X-Original-To: python-id...@python.org
Delivered-To: python-id...@mail.python.org
Received: from albatross.python.org (localhost [127.0.0.1])
	by mail.python.org (Postfix) with ESMTP id 3WgM9G5rnVzPVy;
	Mon, 23 Jul 2012 01:14:26 +0200 (CEST)
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03;
	'subject:Python': 0.05; 'binary': 0.05; 'guido': 0.05; '21,':
	0.07; 'method,': 0.07; 'purpose.': 0.07; 'api': 0.09; 'python':
	0.09; '(it': 0.09; 'doubles': 0.09; 'rossum': 0.09; 'terry': 0.09;
	'threads.': 0.09; 'underlying': 0.09; 'thread': 0.11; "wouldn't":
	0.11; 'read.': 0.13; 'sat,': 0.15; 'from:addr:cs': 0.16;
	'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16;
	'library).': 0.16; 'macosx,': 0.16; 'message-id:@cskk.homeip.net':
	0.16; 'posix': 0.16; 'presume': 0.16; 'readable': 0.16;
	'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16;
	'received:boardofstudies.nsw.edu.au': 0.16;
	'received:cskk.homeip.net': 0.16; 'received:edu.au': 0.16;
	'received:harvey.boardofstudies.nsw.edu.au': 0.16;
	'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'reedy':
	0.16; 'simpson': 0.16; 'subject:ideas': 0.16; 'threads': 0.16;
	'wrote:': 0.17; 'exists': 0.17; 'pointer': 0.17; 'subject:] ':
	0.19; 'equivalent': 0.20; 'exists.': 0.22; "i'd": 0.22; 'cheers,':
	0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1':
	0.24; 'linux': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-
	To:1': 0.25; 'header:User-Agent:1': 0.26; 'extend': 0.26;
	'prevent': 0.27; 'separate': 0.27; 'module.': 0.27; 'locking':
	0.29; 'objects': 0.29; 'van': 0.29; 'probably': 0.29; 'sense':
	0.31; 'implement': 0.32; 'file': 0.32; 'could': 0.32; 'platform,':
	0.33; 'platforms.': 0.33; 'exist': 0.35; 'open': 0.35; 'pm,':
	0.35; 'too.': 0.35; 'something': 0.35; 'there': 0.35;
	'received:au': 0.36; "wasn't": 0.36; 'useful': 0.36; 'should':
	0.36; 'charset:us-ascii': 0.36; 'quite': 0.37; 'data': 0.37;
	'perform': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39;
	'subject:-': 0.40; 'think': 0.40; 'red': 0.60; 'content-
	disposition:inline': 0.60; 'most': 0.61; 'subject:, ': 0.61;
	'future.': 0.62; 'between': 0.63; 'show': 0.63; 'our': 0.65;
	'jul': 0.65; 'fact,': 0.69; 'wish': 0.70; 'amazed': 0.84; 'does!':
	0.84; 'remarks': 0.84; 'say:': 0.84; 'streams': 0.84; 'old.': 0.95
Received: from localhost (HELO mail.python.org) (127.0.0.1)
	by albatross.python.org with SMTP; 23 Jul 2012 01:14:26 +0200
Received: from harvey.boardofstudies.nsw.edu.au
	(mail2.rack1.boardofstudies.nsw.edu.au [202.125.174.133])
	by mail.python.org (Postfix) with ESMTP;
	Mon, 23 Jul 2012 01:14:26 +0200 (CEST)
Received: from janus.cskk.homeip.net (localhost.localdomain [127.0.0.1])
	by harvey.boardofstudies.nsw.edu.au (Postfix) with ESMTP id D48674D3B66;
	Mon, 23 Jul 2012 09:04:30 +1000 (EST)
Received: by janus.cskk.homeip.net (Postfix, from userid 1000)
	id C1D44200578E8; Mon, 23 Jul 2012 09:04:30 +1000 (EST)
Date: Mon, 23 Jul 2012 09:04:30 +1000
From: Cameron Simpson <c...@zip.com.au>
To: Guido van Rossum <gu...@python.org>
Message-ID: <20120722230430.GA15...@cskk.homeip.net>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAP7+vJL=x+agA9CLN1yPwzM74p68w8f6TYWF3kkLPwkd_PF...@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
References: <CAP7+vJL=x+agA9CLN1yPwzM74p68w8f6TYWF3kkLPwkd_PF...@mail.gmail.com>
Cc: python-id...@python.org, Terry Reedy <tjre...@udel.edu>
Subject: Re: [Python-ideas] Atomic file.get(offset, length)
X-BeenThere: python-id...@python.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Discussions of speculative Python language ideas
	<python-ideas.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/python-ideas>,
	<mailto:python-ideas-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-ideas>
List-Post: <mailto:python-id...@python.org>
List-Help: <mailto:python-ideas-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-ideas>,
	<mailto:python-ideas-requ...@python.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org
Errors-To: python-ideas-bounces+python-ideas-garchive-35620=googlegroups....@python.org

On 21Jul2012 13:35, Guido van Rossum <gu...@python.org> wrote:
| On Sat, Jul 21, 2012 at 12:35 PM, Terry Reedy <tjre...@udel.edu> wrote:
| > On 7/21/2012 2:59 PM, Matt Chaput wrote:
| >> I wish Python binary file objects had an atomic seek-read method, so
| >> I wouldn't have to perform my own locking everywhere to prevent other
| >> threads from moving the file pointer between seek and read.
[...]
| >> Is this something that can be bubbled up from the underlying
| >> platform? I think the Linux C equivalent is pread.
[...]
| "man pread" on OS/X suggests it exists there too. I presume the use
| case is to have a large data file open for reading by multiple
| threads. This is a reasonable use case and it makes some sense to
| extend our binary readable streams (buffered and unbuffered) with an
| API for this purpose.

On most Linux boxen you can say:

  man 3p pread

which will show you the POSIX man page, if it exists.

And it does!

So pread will exist on pretty much every UNIX platform, and I'd be
amazed if it wasn't on Windows.

In fact, it remarks that pread appeared in SysVr4, which is quite old.

| However, it's probably just efficient to just have a separate open
| stream per thread

It doubles the system call count per read (if pread is a system call,
which it ually will be (it is on Linux and MacOSX, and is hard to implement
otherwise without an annoying and slow locking scheme concealed inside
the C library).

I'd be +1 for adding pread and pwrite to the os module. It seems
reasonable and quite useful and should work on most platforms.

Cheers,
-- 
Cameron Simpson <c...@zip.com.au>

Rimmer: It will be happened; it shall be going to be happening; it will be
    was an event that could will have been taken place in the future.
        - Red Dwarf, _Future Echoes_
_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas