Re: Two candies

2008-01-02 Thread Aahz
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: > >2) When I use MatchObjects I have to look at the docs to remember the >difference between group() and groups() etc. So I suggest to add a >__getitem__ method to MatchObject, so this: > >mo[3] > >Equals to: > >mo.group(3) Patches are wo

Re: Two candies

2008-01-02 Thread bearophileHUGS
Raymond: >though you have to be very careful about what you measure, how you measure it, >that the system state hasn't changed between measurements, and how your >interpret the results).< Right. This is part of the list of things they teach you to care of when you want to make experiments in bi

Re: Two candies

2008-01-02 Thread Terry Jones
> "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: Raymond> * in most apps (except for sparse arrays), the initialization time Raymond> for an array is dominated by the time spent actually doing Raymond> something useful with the array (iow, this is an odd place to be Raymond> optimiz

Re: Two candies

2008-01-02 Thread Raymond Hettinger
[Raymond] > >#3 is a fine choice. It is memory efficient -- the repeat() itertool > >takes-up only a few bytes. It doesn't need psyco, you already have to fast > >C routines talking to each other without having to go through the > >interpreter loop.< [bearophile] > In my code I have found oth

Re: Two candies

2008-01-02 Thread bearophileHUGS
First of all, thank you Raymond for your answer, and a happy new year to you and to all the Python group :-) Raymond: >#3 is a fine choice. It is memory efficient -- the repeat() itertool takes-up >only a few bytes. It doesn't need psyco, you already have to fast C routines >talking to each ot

Re: Two candies

2008-01-02 Thread Raymond Hettinger
[bearophileH] > > 1) A fast and memory efficient way to create an array.array at a > certain size. > At the moment I can see some ways to do it: > > from array import array > from itertools import repeat > a = array("l", repeat(0, n)) #3 . . . > - #3 interacts badly with Psyco (Psyco doesn't diges

Two candies

2008-01-02 Thread bearophileHUGS
Two little things I may like added. 1) A fast and memory efficient way to create an array.array at a certain size. At the moment I can see some ways to do it: from array import array from itertools import repeat a = array("l", xrange(n)) #1 a = array("l", [0]*n)) #2 a = array("l", repeat(0, n)) #