Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-09-13 09:41:59


Thomas,

Thank you for your interest in contributing to Boost.Python!

I think I was supposed to reply to your previous email, and got distracted
by one of my many responsibilities. I assume you are referring to
http://groups.yahoo.com/group/boost/message/17093. I will try to respond
today.

Regarding your "ref" proposal, there is quite a bit of detail missing, but I
have the following reservations:

1. "ref" is a term used in Boost.Python to refer to a generic Python Object
reference. It is a typedef for boost::python::reference<PyObject>. I think
your use of the term could be confusing.

2. Currently, it is possible to wrap a function taking int const&
parameters: it just works automatically. The reason that no facility for
wrapping int& parameters is provided is that Python ints are immutable. We
don't want people changing them: it would break everything.

3. More importantly, AFAICT it opens a dangerous hole which would allow
users to easily crash Python. If you are holding on to a pointer to some
object which is contained in another Python object, what happens to the
pointer when the Python object it points to is destroyed/garbage collected?
I say "AFAICT" above because I can't see the details of your code, so you
may be doing something utterly different than what I expect.

-Dave

----- Original Message -----
From: "Thomas Malik" <Thomas_Malik%LGBANK_at_[hidden]>

to_python/from_python/make_ref
template functions.
Use is as follows:
in refmodule.cpp:
BOOST_PYTHON_MODULE_INIT(ref)
{
  try
  {
      python::module_builder this_module("ref");
      this_module.def(make_ref<int>, "make_ref");
      this_module.def(make_ref<const char*>, "make_ref");
     ... other reference types needed
  }
  catch(...)
  {
      python::handle_exception();
  }
}

reftest.py
import ref
>> r=ref.make_ref(1)
>> print r
<reference to int object at b4f40>
>> print type(r)
<type 'reference to int'>
>> print r()
1
>> function_with_intref_parameter(r)
>> print r()
10

The whole module is fairly short. Any interest ?

BTW. did my first mail, concerning unsigned char* conversions did get to
the mailing list ?
I didn't receive any comments on it.

--
Thomas Malik
Landesbank Baden-Wuerttemberg (Stuttgart, Germany)
Abt. 2340 Tel. (+49 711) 124-7049
Thomas_Malik%lgbank_at_[hidden]
______________________________________________________________________
----------------------------------------------------------------------------
----------------
Bitte beachten Sie, dass der Inhalt dieser E-Mail einschließlich eventuell
angehängter Dokumente vertraulich ist. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
dürfen Sie die E-Mail und eventuell angehängte Dokumente weder öffnen,
lesen, kopieren, verbreiten noch ihren Inhalt in irgendeiner Weise nutzen.
Bitte verständigen Sie den Absender sofort und löschen Sie die E-Mail
sodann.
Die Sicherheit von Übermittlungen per E-Mail kann nicht garantiert werden.
Per E-Mail übermittelte Informationen können abgefangen oder geändert
werden, verloren gehen oder zerstört werden, verspätet oder unvollständig
ankommen, oder Viren enthalten. Der Absender übernimmt daher keine Gewähr
für Irrtümer oder Auslassungen jeder Art im Inhalt sowie sonstige Risiken,
die auf die Übermittlung per E-Mail zurückzuführen sind. Falls Sie eine
Bestätigung wünschen, fordern Sie bitte den Inhalt der E-Mail als Hardcopy
an.
This e-mail and any attached files are confidential. If you are not the
named addressee or if this transmission has been addressed to you in error,
any disclosure, reproduction, copying, distrubtion, or other dissemination
or use of this communication is prohibited. If you have received this
transmission in error please notify the sender immediately and then delete
this e-mail.
E-mail transmission cannot be guaranteed to be secure or free from error as
information could be intercepted, corrupted, lost, destroyed, arrive late
or incomplete, or contain viruses. The sender therefore does not accept
liability for any errors or omissions in the contents of this message or
any other of such risks which arise as a result of e-mail transmission. If
verification is required, please request a hard copy version.
----------------------------------------------------------------------------
-----------------
Info: http://www.boost.org  Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk