[SciPy-dev] Weave - strange behaviour

Manuel Metz mmetz at astro.uni-bonn.de
Wed Sep 22 04:29:41 CDT 2004


Hi,
I was really excited about weave. But I found a (to me) somewhat strange 
behaviour, which I do not understand. I used the following code to test 
weave:

[...]
class test(object):
     def wtest(self):
         a = numarray.array( [1,2,3] )
         assert( type(a)==type( numarray.array([]) ) )

         ccode2 = """
         int val;
         using namespace std;
         for(int i=0; i<a.length(); i++) {
             val = py_to_int( a[i], "val" );
             cout << val << endl;
         }"""

         weave.inline( ccode2, ["a",] )
[...]

Okay, the code worked fine, output of the program was:
 >>>>>
file changed
None
1
2
3
<<<<<

Now if I only change the last line of the C-code from
         }"""
to
         }
         """
so nothing more than just a line-break, I always (even after the C-code
is already compiled) get the following output:

 >>>>>
repairing catalog by removing key
file changed
None
1
2
3
<<<<<

And it seams that EACH time I call the function the C-code gets 
compiled. This behavior also showed up depending on the first line of 
the C-code (line break or not; additionen spaces).

Has anyone else seen this? Any idea what is going wrong? How can I 
prevent this strange behaviour (except try and error)?

My system:
- Debian linux (testing)
- Package: python2.3-scipy
   Version: 0.3.0+266.4239-1

Manuel
-- 
-------------------------------------
  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