diff options
author | Eric Jones <eric@enthought.com> | 2002-10-10 09:05:34 +0000 |
---|---|---|
committer | Eric Jones <eric@enthought.com> | 2002-10-10 09:05:34 +0000 |
commit | b9e184cb5bc0f9c2fa2aa4d4e78b6c45541fa73a (patch) | |
tree | c3c489013197cb2fa5f91ac63c598eb87253f7bb /weave/examples/fibonacci.py | |
parent | 6978ceae6b1f69395d700f7c5a464dd45665ec88 (diff) | |
download | numpy-b9e184cb5bc0f9c2fa2aa4d4e78b6c45541fa73a.tar.gz |
This checkin marks a fairly substantial change in the C++ classes for
weave. The original SCXX code has been augmented and mutated to the
point of not be recognizable as SCXX any more. File and class names
have moved more toward boost naming conventions.
The most significant change is that, when writing standard inline()
code, end users are not responsible for reference counting at all.
Additionally, casting functions have been added and methods have
been overloaded so that conversions between python types and C
types are handled transparently for the basic types (char*,int,float,
double,std::string,std::complex<double>, etc.)
py::object has been augmented to handle attribute access, function
calling, method calling, and pretty much all of the rest of the
PyObject_xxx API.
This is near feature complete for weave 0.3. The remaining tasks are
to test on other platforms and re-write the documentation.
Diffstat (limited to 'weave/examples/fibonacci.py')
-rw-r--r-- | weave/examples/fibonacci.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/weave/examples/fibonacci.py b/weave/examples/fibonacci.py index 6fbe9d2bf..3905ccd04 100644 --- a/weave/examples/fibonacci.py +++ b/weave/examples/fibonacci.py @@ -1,13 +1,13 @@ # Typical run: -# C:\home\ej\wrk\scipy\compiler\examples>python fibonacci.py +# C:\home\eric\wrk\scipy\weave\examples>python fibonacci.py # Recursively computing the first 30 fibonacci numbers: -# speed in python: 3.98599994183 -# speed in c: 0.0800000429153 -# speed up: 49.82 -# Loopin to compute the first 30 fibonacci numbers: -# speed in python: 0.00053100001812 -# speed in c: 5.99999427795e-005 -# speed up: 8.85 +# speed in python: 4.31599998474 +# speed in c: 0.0499999523163 +# speed up: 86.32 +# Looping to compute the first 30 fibonacci numbers: +# speed in python: 0.000520999908447 +# speed in c: 5.00000715256e-005 +# speed up: 10.42 # fib(30) 832040 832040 832040 832040 import sys @@ -31,8 +31,7 @@ def build_fibonacci(): } """ ext_code = """ - int val = fib1(a); - return_val = PyInt_FromLong(val); + return_val = fib1(a); """ fib = ext_tools.ext_function('c_fib1',ext_code,['a']) fib.customize.add_support_code(fib_code) @@ -58,8 +57,7 @@ def build_fibonacci(): } """ ext_code = """ - int val = fib2(a); - return_val = PyInt_FromLong(val); + return_val = fib2(a); """ fib = ext_tools.ext_function('c_fib2',ext_code,['a']) fib.customize.add_support_code(fib_code) |