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


Groups > comp.lang.python > #2582

Re: Python CPU

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Python CPU
Date 2011-04-04 14:58 -0400
References (2 earlier) <4d97f125$0$29992$c3e8da3$5496439d@news.astraweb.com> <4d981eb5$0$10581$742ec2ed@news.sonic.net> <8vtbclF7q4U1@mid.individual.net> <7xoc4mmkt9.fsf@ruckus.brouhaha.com> <incua1$j5m$1@dough.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.15.1301943516.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 4/4/2011 1:14 PM, Terry Reedy wrote:
> On 4/4/2011 5:23 AM, Paul Rubin wrote:
>> Gregory Ewing<greg.ewing@canterbury.ac.nz> 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

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


Thread

Python CPU Brad <hwfwguy@gmail.com> - 2011-04-01 08:38 -0700
  Re: Python CPU jkn <jkn_gg@nicorp.f9.co.uk> - 2011-04-01 08:59 -0700
  Re: Python CPU Nobody <nobody@nowhere.com> - 2011-04-01 17:52 +0100
    Re: Python CPU Stefan Behnel <stefan_ml@behnel.de> - 2011-04-01 19:00 +0200
    Re: Python CPU geremy condra <debatem1@gmail.com> - 2011-04-01 10:12 -0700
  Re: Python CPU Emile van Sebille <emile@fenx.com> - 2011-04-01 11:28 -0700
  Re: Python CPU Emile van Sebille <emile@fenx.com> - 2011-04-01 11:35 -0700
    Re: Python CPU John Nagle <nagle@animats.com> - 2011-04-01 12:18 -0700
  Re: Python CPU "BartC" <bc@freeuk.com> - 2011-04-02 23:06 +0100
    Re: Python CPU Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-03 04:03 +0000
  Re: Python CPU Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-03 12:10 +1200
    Re: Python CPU Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-03 04:01 +0000
      Re: Python CPU John Nagle <nagle@animats.com> - 2011-04-03 00:16 -0700
        Re: Python CPU Paul Rubin <no.email@nospam.invalid> - 2011-04-03 01:59 -0700
          Re: Python CPU Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-04 19:41 +1200
        Re: Python CPU Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-04 19:47 +1200
          Re: Python CPU Paul Rubin <no.email@nospam.invalid> - 2011-04-04 02:23 -0700
            Re: Python CPU Terry Reedy <tjreedy@udel.edu> - 2011-04-04 13:14 -0400
            Re: Python CPU Terry Reedy <tjreedy@udel.edu> - 2011-04-04 14:58 -0400
              Re: Python CPU Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-05 09:59 +1200
          Re: Python CPU geremy condra <debatem1@gmail.com> - 2011-04-04 09:36 -0700
            Re: Python CPU Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-05 10:05 +1200
          Re: Python CPU John Nagle <nagle@animats.com> - 2011-04-04 12:56 -0700
            Re: Python CPU Paul Rubin <no.email@nospam.invalid> - 2011-04-04 13:20 -0700
              Re: Python CPU Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-05 10:11 +1200
    Re: Python CPU Werner Thie <werner@thieprojects.ch> - 2011-04-03 17:44 +0200
      Re: Python CPU John Nagle <nagle@animats.com> - 2011-04-03 10:15 -0700
        Re: Python CPU Nobody <nobody@nowhere.com> - 2011-04-03 22:37 +0100
          Re: Python CPU Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-04-03 22:59 -0700

csiph-web