[C++-SIG] setattr and CXX-4.2

Geoffrey Furnish furnish at actel.com
Wed May 17 01:43:50 CEST 2000


The getattr signature is determined by the Python core.  We can't
really change that without reworking more of the Python guts, which
doesn't seem very feasible to me.  Also, it would just force the
caller of getattr to run strlen on the string anyway, so I don't
really see a net performance improvement coming from this.

Steve Harris writes:
 > "Barry Scott" <barry at scottb.demon.co.uk> writes:
 > 
 > [...]
 > 
 > > Here is an example taken from CXX\Demo\r.cxx
 > > 
 > > Py::Object r::getattr( const char *name )
 > > {
 > >     if(std::string(name) == "c")
 > > 		return Py::Float(300.0);
 > > 
 > >     if(std::string(name) == "start")
 > > 		return Py::Int(start);
 > > 
 > >     return getattr_methods( name );
 > > }
 > 
 > Would it be possible to get a length argument in addition to the const
 > char* argument, if we're not getting a const std::string& as a
 > parameter? That is, if the length of the string is known "upstream,"
 > it would be convenient to have it here to both speed comparisons or to
 > construct a std::string as you've shown here. If the string hasn't
 > even been examined yet, then this would not be an option here.
 > 
 > -- 
 > Steven E. Harris
 > Primus Knowledge Solutions, Inc.
 > http://www.primus.com
 > 
 > _______________________________________________
 > C++-SIG maillist  -  C++-SIG at python.org
 > http://www.python.org/mailman/listinfo/c++-sig
 > 




More information about the Cplusplus-sig mailing list