[SciPy-dev] Bugfix for weave's catalog.

Manuel Metz mmetz at astro.uni-bonn.de
Fri Jun 17 02:36:26 EDT 2005


I do see the same behavior described below on my Linux box:
*Only* on the second iteration I get "repairing catalog by removing key"...

Debian Linux (i386), sid, python 2.3.5, weave 0.3.2
(the actual package versions on Debian)

Manuel

John Hunter schrieb:
>>>>>>"Fernando" == Fernando Perez <Fernando.Perez at colorado.edu> writes:
> 
> 
>     Fernando> Actually, I just checked and that stuff never made it to
>     Fernando> SVN, so I don't have it.  Could you either commit it or
>     Fernando> mail it to me so I can test and see if my fix also works
>     Fernando> for your code?
> 
> Here is the script that shows the bug.  It is designed to compare the
> performance of weave blitz versus numeric for repeated adds of a 2D
> array
> 
>   x + x
>   x + x + x
>   x + x + x + x   ....and so on
> 
> On the second iteration through the loop (x+x+x), it issues a
> "repairing catalog by removing key" and recompiles the extensions --
> it doesn't do this for any other of the repeated add lines in this
> loop.  This happens repeatedly if you rerun the script, so the cache
> is being ignored.  Unfortunately, I only see this on my G4 powerbook
> and not on my linux box, so it might be hard for others to use as a
> test script.
> 
> Tomorrow I'll try and update scipy weave on my powerbook from CVS and
> try it with and w/o your patch.
> 
> JDH
> 
> from __future__ import division
> import sys, time
> from Numeric import zeros, Float
> from MLab import rand
> import weave
> from pylab import subplot, plot, show, legend, xlabel, ylabel, title
> 
> 
> shape = 200,200
> x = rand(*shape)
> 
> 
> def repeat_nadds(Nadds, Nevals, useWeave):
>     """
>     Time the addition of i=2,Nadds arrays.  Evaluate each expression
>     Nevals times to produce accurate timing results.  If useWeave is
>     True, use weave to inline the addition, else use Numeric
> 
>     return value is n,t where n is a list of the the number of arrays
>     added and t is the average time it took to add the arrays
>     """
>     results = []
>     for i in range(2,Nadds):
>         s = 'result = %s' % '+'.join(['x']*i)
>         print 'evaluating: %s with weave=%s' % (s,useWeave)
>         tstart = time.time()
> 
>         # only weave needs to predefine result array
>         if useWeave: result= zeros(shape, typecode=Float)
>         for j in range(Nevals):
>             if useWeave:
>                 weave.blitz(s)
>             else:
>                 exec(s)
>         elapsed = (time.time()-tstart)/Nevals
>         print '\tNadds=%d  Elapsed=%1.2f' % (i, elapsed)
>         results.append( (i, elapsed) )
>     return zip(*results)
>         
> Nadds = 7
> Nevals = 20
> 
> # evaluate weave 
> nw, tw = repeat_nadds(Nadds, Nevals, useWeave=True)
> # evaluate Numeric
> nn, tn = repeat_nadds(Nadds, Nevals, useWeave=False)
> 
> # plot weave versus Numeric
> ax = subplot(111)
> plot(nw, tw, 'go', nn, tn, 'bs')
> legend( ('Weave', 'Numeric') )
> xlabel('num adds')
> ylabel('time (s)')
> title('Numeric vs weave; repeated adds')
> ax.set_xlim( (0, Nadds+1))
> show()       
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev

-- 
-------------------------------------
  Manuel Metz
  Sternwarte der Universitaet Bonn
  Auf dem Huegel 71 (room 3.06)
  D - 53121 Bonn

  E-Mail: mmetz at astro.uni-bonn.de
  Phone:  (+49) 228 / 73-3660
  Fax:    (+49) 228 / 73-3672
-------------------------------------




More information about the SciPy-Dev mailing list