<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 25: Add better support for conversion to native Python types in public API</title><link>https://sourceforge.net/p/pythonnet/patches/25/</link><description>Recent changes to 25: Add better support for conversion to native Python types in public API</description><atom:link href="https://sourceforge.net/p/pythonnet/patches/25/feed.rss" rel="self"/><language>en</language><lastBuildDate>Thu, 26 Sep 2013 18:15:27 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/pythonnet/patches/25/feed.rss" rel="self" type="application/rss+xml"/><item><title>Add better support for conversion to native Python types in public API</title><link>https://sourceforge.net/p/pythonnet/patches/25/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The attached patch improves support for converting managed values (reference or boxed values) to the corresponding Python types.&lt;/p&gt;
&lt;p&gt;This support had previously been partly implemented in Converter.ToPython() but it was not exposed in the public interface of PyObject (if I'm not mistaken), which made it hard for me to call Python functions from managed code in an embedding scenario. My patch makes the following changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;adds PyObject.FromManagedValue() which tries to convert a given managed object to an appropriate builtin Python type&lt;/li&gt;
&lt;li&gt;adds Converter.ToPythonValue() which does the same thing as Converter.ToPython() except that it converts managed arrays to Python lists where appropriate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Being not very familiar with the Python for .NET codebase, I didn't have the heart to build my array support directly into Converter.ToPython(). However I'd be happy if the array handling code could go to Converter.ToPython() in order to avoid having two similarly-named functions (.ToPython() and .ToPythonValue()) which differ in a non-obvious way, so if that is considered appropriate, please move it there.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Moritz Beutel</dc:creator><pubDate>Thu, 26 Sep 2013 18:15:27 -0000</pubDate><guid>https://sourceforge.netc3d944a324cafe03e2a6baaeec74ef0083d46715</guid></item></channel></rss>