pyd.make_object

This module contains some useful type conversion functions. The two most interesting operations here are python_to_d and d_to_python.

Additionally, the py function is provided as a convenience to directly convert a D object into an instance of PydObject.

To convert a PydObject to a D type, use PydObject.to_d.

Members

Aliases

datetime_datetime
alias datetime_datetime = get_type!("datetime", "datetime")
Undocumented in source.
numpy_datetime64
alias numpy_datetime64 = get_type!("numpy", "datetime64")
Undocumented in source.
python_to_d_Object
alias python_to_d_Object = python_to_d!(Object)
Undocumented in source.

Classes

PydConversionException
class PydConversionException

An exception class used by python_to_d.

from_conversion_wrapper
class from_conversion_wrapper(dg_t)
Undocumented in source.
to_conversion_wrapper
class to_conversion_wrapper(dg_t)
Undocumented in source.

Functions

PyTuple_FromItems
PyObject* PyTuple_FromItems(T t)

Helper function for creating a PyTuple from a series of D items.

could_not_convert
void could_not_convert(PyObject* o, string reason, string file, size_t line)
Undocumented in source. Be warned that the author may not have intended to support it.
d_aarray_to_python
PyObject* d_aarray_to_python(T t)
Undocumented in source. Be warned that the author may not have intended to support it.
d_array_to_python
PyObject* d_array_to_python(T t)
Undocumented in source. Be warned that the author may not have intended to support it.
d_bigint_to_python
PyObject* d_bigint_to_python(BigInt t)
Undocumented in source. Be warned that the author may not have intended to support it.
d_string_to_python
PyObject* d_string_to_python(T t)
Undocumented in source. Be warned that the author may not have intended to support it.
d_to_python
PyObject* d_to_python(T t)

Returns a new (owned) reference to a Python object based on the passed argument. If the passed argument is a PyObject*, this "steals" the reference. (In other words, it returns the PyObject* without changing its reference count.) If the passed argument is a PydObject, this returns a new reference to whatever the PydObject holds a reference to.

d_to_python_array_array
PyObject* d_to_python_array_array(T t)

Convert a d array to a python array.array. array.array does not support 8 byte integers.

d_to_python_bytes
PyObject* d_to_python_bytes(T t)

Convert a D object to python bytes (str, in python 2).

d_to_python_try_extends
PyObject* d_to_python_try_extends(T t)
Undocumented in source. Be warned that the author may not have intended to support it.
d_tuple_to_python
PyObject* d_tuple_to_python(T t)
Undocumented in source. Be warned that the author may not have intended to support it.
ex_d_to_python
void ex_d_to_python(dg_t dg)

Extend pyd's conversion mechanism. Will be used by d_to_python only if d_to_python cannot convert its argument by regular means.

ex_python_to_d
void ex_python_to_d(dg_t dg)

Extend pyd's conversion mechanims. Will be used by python_to_d only if python_to_d cannot convert its argument by regular means.

init_rangewrapper
void init_rangewrapper()
Undocumented in source. Be warned that the author may not have intended to support it.
isNumpyBool
bool isNumpyBool(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
isNumpyComplexNumber
bool isNumpyComplexNumber(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
isNumpyFloat
bool isNumpyFloat(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
isNumpyInteger
bool isNumpyInteger(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
isNumpyNumber
bool isNumpyNumber(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
isPyNumber
bool isPyNumber(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
is_numpy_datetime64
bool is_numpy_datetime64(PyObject* py)
Undocumented in source. Be warned that the author may not have intended to support it.
match_format_type
bool match_format_type(string format)

Check T against format

py
PydObject py(T t)

Constructs an object based on the type of the argument passed in.

python_array_array_to_d
T python_array_array_to_d(PyObject* o)

Convert an array.array object to a D object.

python_buffer_to_d
T python_buffer_to_d(PyObject* o)

Convert a Python new-style buffer to a D object.

python_iter_to_d
T python_iter_to_d(PyObject* o)

Convert an iterable Python object to a D object.

python_to_aarray
T python_to_aarray(PyObject* py)
Undocumented in source. Be warned that the author may not have intended to support it.
python_to_d
T python_to_d(PyObject* o)

This converts a PyObject* to a D type. The template argument is the type to convert to. The function argument is the PyObject* to convert. For instance:

python_to_d_bigint
T python_to_d_bigint(PyObject* o)
Undocumented in source. Be warned that the author may not have intended to support it.
python_to_d_complex
T python_to_d_complex(PyObject* o)
Undocumented in source. Be warned that the author may not have intended to support it.
python_to_d_numpy_datetime64
T python_to_d_numpy_datetime64(PyObject* py)
Undocumented in source. Be warned that the author may not have intended to support it.
python_to_d_string
T python_to_d_string(PyObject* o)
Undocumented in source. Be warned that the author may not have intended to support it.
python_to_d_try_extends
T python_to_d_try_extends(PyObject* o)
Undocumented in source. Be warned that the author may not have intended to support it.
python_to_d_tuple
T python_to_d_tuple(PyObject* o)
Undocumented in source. Be warned that the author may not have intended to support it.
to_python_int
PyObject* to_python_int(PyObject* o)
Undocumented in source. Be warned that the author may not have intended to support it.
type_name
const(char)[] type_name(PyObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
wrap_range
auto wrap_range(Range range)

Wrap a D input range as a python iterator object.

Properties

array_array_Type
PyTypeObject* array_array_Type [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

RangeWrapper
struct RangeWrapper

Wrapper type wrapping a D input range as a python iterator object

arraydescr
struct arraydescr
Undocumented in source.
arrayobject
struct arrayobject
Undocumented in source.

Templates

IsStaticArrayPointer
template IsStaticArrayPointer(T)

Check that T is a pointer to a rectangular static array.

MatrixInfo
template MatrixInfo(T)

Some reflective information about multidimensional arrays

SimpleFormatType
template SimpleFormatType(T)

generate a struct format string from T

from_converter_registry
template from_converter_registry(To)
Undocumented in source.
get_type
template get_type(string _module, string type_name)
Undocumented in source.
to_converter_registry
template to_converter_registry(From)
Undocumented in source.

Variables

rangeWrapperInited
bool rangeWrapperInited;
Undocumented in source.

Meta