implicit conversion

From: Benjamin Schmeling (Benjamin_Schmeling_at_gmx.de)
Date: 01/31/05


Date: Mon, 31 Jan 2005 14:01:56 +0100
To: python-list@python.org

Hi,

I am working on exposing a bigint class to python. Now I've got the
problem that methods which take an bigint as
an parameter do not accept Python longs.

For example:
import _PythonLiDIA
x=123L;
c=_PythonLiDIA.bigint();
_PythonLiDIA.gcd(c,x);

Traceback (most recent call last):
File "test.py", line 132, in ?
  _PythonLiDIA.gcd(a,x);
Boost.Python.ArgumentError: Python argument types in
  _PythonLiDIA.gcd(bigint, long)
did not match C++ signature:
  gcd(LiDIA::bigint, LiDIA::bigint)

I don't know how to achieve implicit conversion at this point, turning an
long automatically into an bigint. The other way round, turning an bigint
into long can be realized by defining __long__.

Can someone help me please?

Benjamin



Relevant Pages

  • Re: implicit conversion
    ... > I am working on exposing a bigint class to python. ... The other way round, turning an bigint ...
    (comp.lang.python)
  • Re: Python C module questions
    ... > I'm rather new to Python, and I've just written my first Python C ... You mean a docstring on the module object itself? ... This module consisted of turning 4 Python sequences into C double ... > arrays, performing some calculations, and then turning a C int array ...
    (comp.lang.python)
  • Re: implicit conversion
    ... Alex Martelli wrote: ... >> long automatically into an bigint. ... The other way round, turning an ... implicit conversion from long to my_type isn't supported. ...
    (comp.lang.python)
  • Best way to process table rows from an RDBMS
    ... I can handle making the connections and running queries, ... best way to process table rows returned in Python? ... What about turning a ... regularly processing a fixed set of tables with a certain fixed set of ...
    (comp.lang.python)
  • Re: implicit conversion
    ... Benjamin Schmeling wrote: ... The other way round, turning an bigint ...
    (comp.lang.python)