Re: [C++-sig] How to converter std::string* in boost.python?

2012-12-24 Thread simon zhang
If Jim is right,string's memory allocated is different in python and c++.However,before python handle some strings from c++,it must convert string from c++'s memory to python's memory. So smart pointers have not changed anything.It must keep a separate copy of a string in c++ memory and python mem

Re: [C++-sig] How to converter std::string* in boost.python?

2012-12-24 Thread Niall Douglas
Traditionally, the proper solution to avoid deep copies is to wrap a std::shared_ptr instead of a std::string directly. If your strings are short of course, it may well be faster to leave it as is. std::shared_ptr is not lightweight and may use atomic instructions, the bandwidth for which in a

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-24 Thread Niall Douglas
In your C++ you simply need to ensure that Python gets a regular chance to execute in any native loop you execute so it can do its housekeeping. One way is PyErr_CheckSignals(), but that won't do for long running loops, only short ones, because it doesn't do much housekeeping. In my own code I