Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.04; 'parameter': 0.05; 'terry': 0.07; 'wrapper': 0.07; 'python': 0.07; '(possibly': 0.09; 'bytes,': 0.09; 'ctypes': 0.09; 'presume': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'pm,': 0.11; '>>>': 0.12; 'def': 0.13; 'am,': 0.14; 'extension': 0.14; 'wrote:': 0.14; 'library': 0.15; 'arrays,': 0.16; 'fold': 0.16; 'functools': 0.16; 'hardware.': 0.16; 'methods,': 0.16; 'numpy': 0.16; 'reedy': 0.16; 'thought.': 0.16; 'useful,': 0.16; 'posting': 0.18; 'bytes': 0.19; 'generic': 0.19; 'wrap': 0.19; 'writes:': 0.20; 'jan': 0.22; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'gregory': 0.23; 'point,': 0.25; 'equivalent': 0.26; 'object': 0.27; 'pass': 0.27; 'shared': 0.29; 'needed,': 0.29; 'class': 0.29; 'functions.': 0.29; 'arrays': 0.31; 'ewing': 0.31; 'data,': 0.31; 'paul': 0.32; 'to:addr:python-list': 0.32; 'done': 0.32; 'idea': 0.32; "i've": 0.33; 'things': 0.33; 'array': 0.33; 'module': 0.33; 'thinking': 0.33; 'header:X-Complaints-To:1': 0.34; 'question': 0.35; 'header:User-Agent:1': 0.35; 'recognize': 0.35; 'enough': 0.37; 'useful': 0.37; 'helped': 0.38; 'sequence': 0.38; 'strings': 0.38; 'but': 0.38; 'received:org': 0.38; 'help': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'comes': 0.39; 'header:Mime-Version:1': 0.39; 'map': 0.40; 'would': 0.40; 'header:Received:5': 0.40; 'might': 0.40; 'units': 0.60; 'simple': 0.60; 'cost': 0.63; 'harder': 0.65; 'saving': 0.72; 'have.': 0.73; 'from.': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python CPU Date: Mon, 04 Apr 2011 14:58:20 -0400 References: <01bd055b-631d-45f0-90a7-229da4a9a362@t19g2000prd.googlegroups.com> <8vps7tF9vuU1@mid.individual.net> <4d97f125$0$29992$c3e8da3$5496439d@news.astraweb.com> <4d981eb5$0$10581$742ec2ed@news.sonic.net> <8vtbclF7q4U1@mid.individual.net> <7xoc4mmkt9.fsf@ruckus.brouhaha.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 41 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301943517 news.xs4all.nl 81474 [::ffff:82.94.164.166]:50814 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2582 On 4/4/2011 1:14 PM, Terry Reedy wrote: > On 4/4/2011 5:23 AM, Paul Rubin wrote: >> Gregory Ewing writes: >>> What might help more is having bytecodes that operate on >>> arrays of unboxed types -- numpy acceleration in hardware. >> >> That is an interesting idea as an array or functools module patch. >> Basically a way to map or fold arbitrary functions over arrays, with a >> few obvious optimizations to avoid refcount churning. It could have >> helped with a number of things I've done over the years. > > For map, I presume you are thinking of an array.map(func) in system code > (C for CPython) equivalent to > > def map(self,func): > for i,ob in enumerate(self): > self[i] = func(ob) > > The question is whether it would be enough faster. Of course, what would > really be needed for speed are wrapped system-coded funcs that map would > recognize and pass and received unboxed array units to and from. At that > point, we just about invented 1-D numpy ;-). > > I have always thought the array was underutilized, but I see now that it > only offers Python code space saving at a cost of interconversion time. > To be really useful, arrays of unboxed data, like strings and bytes, > need system-coded functions that directly operate on the unboxed data, > like strings and bytes have. Array comes with a few, but very few, > generic sequence methods, like .count(x) (a special-case of reduction). After posting this, I realized that ctypes makes it easy to find and wrap functions in a shared library as a Python object (possibly with parameter annotations) that could be passed to array.map, etc. No swigging needed, which is harder than writing simple C functions. So a small extension to array with .map, .filter, .reduce, and a wrapper class would be more useful than I thought. -- Terry Jan Reedy