[C++-sig] Mapping C++ typedefs to Python

Roman Yakovenko roman.yakovenko at gmail.com
Wed Nov 7 19:00:53 CET 2007


On 11/7/07, Nat Goodspeed <nat at lindenlab.com> wrote:
>
> Sylvain Pion wrote:
>
> > I use typedefs in C++, that is, several names for the same type
> > (enums in my case).
> > Is it possible to export this in Python?
> > Is there the equivalent of typedefs in Python, and how
> > can I specify this using Boost.Python?
>
> enums:
>
>
> http://boost.org/libs/python/doc/tutorial/doc/html/python/object.html#python.enums
>
> If you have several C++ names for the same type, wouldn't it work to
> export each of them as though they were distinct? Unless I'm missing
> something, neither Python nor Boost.Python needs to know their sameness.


This approach introduces compile & size overhead, plus you will get few
warnings during module loading.

The better one is to wrap exposed module with Python package and to add all
aliases within it.
For example:
http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/examples/pyboost_dev/pyboost/date_time/__init__.py?revision=642&view=markup

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20071107/4eaab73b/attachment.htm>


More information about the Cplusplus-sig mailing list