2009/6/7 Taner Yildirim <ta...@seas.upenn.edu> > Dear Gustavo, > > > > Thanks for the detailed explanation, which fixed the problem!. As I > indicated in my previous email, I am mainly a Fortran programmer and do not > have much experience with c++. I used to wrap my programs with F2Py but then > decided to do right thing and learn c/c++ and rewrite some of the > applications. Thanks to your pybindgen code, the wrapping them for python > would be the easiest part!! > > > > Back to pybindgen containers, I noticed a strange behavior. I did not check > the bug reports. Sorry if this was already reported. > > I have the following code: > > > > mod=Module('tst1') > > mod.add_include('"tst1.h"') > > mod.add_container('std::vector<int>', 'int', > 'vector',custom_name="std_vec_int") > > > > In python, I do this: > > > > A=std_vec_int([1,2,3]) > > B=std_vec_int([1,2,3]) > > > > But then > > A==B returns false??? > > > > Similarly, I do c=std_vec_int(a) and then check a==c which returns false!!! >
Type comparison, like many other things, is not yet implemented in pybindgen. Like I said, you can do a lot of things by simply "casting" in python to a list, i.e. instead of: A=std_vec_int([1,2,3]) do: A=list(std_vec_int([1,2,3])) It's an ugly workaround but it works ok (although the performance isn't great). > > > If I do list(A) and list(B), I get the right list. It looks like “==” not > working or I am again missing something very trivial! > You are not missing anything, it's just not implemented. Unfortunately Python 2.x has some default comparison function; this is fixed in Python 3.x, which just raises an exception if the comparison operation is not implemented. > By the way, this observation is based on pybindgen-0.10.0 and mingw (gcc > 4.4.0). > > > > Best regards > > Taner > > > > > ******************************************************************************** > Dr. Taner Yildirim, Ph.D. Physicist, > Adjunct Associate Professor, > Materials Science and Engineering, > University of Pennsylvania > and > Computational and Neutron Science Team Leader, > NIST Center for Neutron Research, > National Institute of Standards and Technology, > 100 Bureau Drive, Gaithersburg, MD 20899-6100. > Email: ta...@nist.gov or ta...@seas.upenn.edu > PHONE: 301-975-6228 FAX : 301-921-9847 > Web : http://webster.ncnr.nist.gov/staff/taner > > ******************************************************************************** > > > -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig