Stefan,
To: cplusplus-sig@python.org Subject: Re: [C++-sig] Passing memory allocated in C++ to Python Message-ID: <56945036.8080...@seefeld.name> Content-Type: text/plain; charset=windows-1252 > Essentially- Python needs access to the return value from a malloc() call. >>Really ? Why ? You say your C++ code needs to access the pointer(s). >>Python has no notion of "pointer", but it will happily pass around >>atever data you expose from C++. Sorry about that Stefan, my post should have been clearer. I know Python doesn't know about pointers. I should have said "Python needs access to the memory pointed to by the memory allocated with malloc()". >>f you expose the above class together with the constructor and thei >>'call_ioctl()' member function I think you have all you need. In your something class, the data type returned from allocate_memory() needs to be something that Python understands. Since that allocation function (member) will be allocating 100s of MB of memory, how will this memory map to a Python data type? Is a bytearray better to use than a list (as far as performance is concerned)? Is a list better to use than a string (as far as performance is concerned). Are there other data types that should be considered? The user will need to access that data as bytes, words, longs, and possibly sequences. I've tried using boost's extract, to convert the char * returned from malloc() into a Python string, and a Python list, but these result in compile errors.
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig