CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Fri, 18 Jul 2025 04:12:43 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Thu, 11 Aug 2011 03:54:26 GMT
x-archive-orig-server: Apache/2.2.16 (Debian)
x-archive-orig-vary: Cookie,User-Agent,Accept-Language
x-archive-orig-set-cookie: MOIN_SESSION_80_ROOT_moin=de82d2123f1fc3a83f5a301f8e39550d40b90e66; expires=Thu, 11-Aug-2011 04:54:00 GMT; Max-Age=3600; Path=/
x-archive-orig-content-length: 12825
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Thu, 11 Aug 2011 03:54:26 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Sun, 10 Sep 2006 20:09:47 GMT", ; rel="prev memento"; datetime="Mon, 24 Dec 2007 00:16:12 GMT", ; rel="memento"; datetime="Thu, 11 Aug 2011 03:54:26 GMT", ; rel="next memento"; datetime="Sat, 12 Nov 2011 19:17:54 GMT", ; rel="last memento"; datetime="Tue, 10 Sep 2024 03:58:29 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: WPO-20110811024747-crawl438/WPO-20110811035254-01490.warc.gz
server-timing: captures_list;dur=0.559015, exclusion.robots;dur=0.021994, exclusion.robots.policy;dur=0.009449, esindex;dur=0.012375, cdx.remote;dur=32.846970, LoadShardBlock;dur=106.263379, PetaboxLoader3.datanode;dur=122.040587, PetaboxLoader3.resolve;dur=165.282762, load_resource;dur=205.900408
x-app-server: wwwb-app211
x-ts: 200
x-tr: 395
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app211; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
boost.python/extract - PythonInfo Wiki
User
extractor interface which can be used to extract C++ types from Python objects.
We have discussed two main use cases for extractions
1. In user code which needs to retrieve C++ objects from their corresponding Python objects:
- Getting value:
void f(object x) { int y = extract<int>(x); // retrieve an int from x }
- Users may also want to explicitly check for convertibility:
int g(object x) { extract<int> get_int(x); if (get_int.check()) return get_int(); else return 0; }
Example:
- In order to extract elements out of complex structures such as lists and tuples, we must nest extraction calls. The reason for this example is that it may not be immediately obvious to do this. Let's say you have a C++ class that contains a python-usable boost::python::list:
class A { public: boost::python::list list; void listOperation(list& l); };
Then you expose the class to python as:
class_<A>("A") .def_readwrite("b", &A::list) .def("op", &A::listOperation) ;
It is completely reasonable for python script to do something like this:
a = A() a.b = [(1,2),(3,4),(5,6)] a.op(a.b)
In order for you to extract the elements of tuples within the list, we use the index operator of the list:
void A::listOperation(list& l) { // Extract first element of first tuple in the list. extract<int>(extract<tuple>(list[0])())(); }
2. In the implementation of sequence from_python converters (e.g. Python tuple/list -> std::vector)
boost.python/extract (last edited 2008-11-15 14:00:41 by localhost)