diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 8a1c05306..2518f77fb 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.5.12 +current_version = 1.0.5.13 parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? serialize = {major}.{minor}.{patch}.{release}{dev} diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index cf9bb4749..3aa2d1a62 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -1,6 +1,6 @@ package: name: pythonnet - version: "1.0.5.12" + version: "1.0.5.13" build: skip: True # [not win] diff --git a/setup.py b/setup.py index d35041876..3695e33fa 100644 --- a/setup.py +++ b/setup.py @@ -485,7 +485,7 @@ def run(self): setup( name="pythonnet", - version="1.0.5.12", + version="1.0.5.13", description=".Net and Mono integration for Python", url='https://pythonnet.github.io/', license='MIT', diff --git a/src/SharedAssemblyInfo.cs b/src/SharedAssemblyInfo.cs index 4a3b83782..e9d39ba33 100644 --- a/src/SharedAssemblyInfo.cs +++ b/src/SharedAssemblyInfo.cs @@ -25,4 +25,4 @@ // Version Information. Keeping it simple. May need to revisit for Nuget // See: https://codingforsmarties.wordpress.com/2016/01/21/how-to-version-assemblies-destined-for-nuget/ // AssemblyVersion can only be numeric -[assembly: AssemblyVersion("1.0.5.12")] +[assembly: AssemblyVersion("1.0.5.13")] diff --git a/src/runtime/converter.cs b/src/runtime/converter.cs index a33ade002..d8ec3fcd2 100644 --- a/src/runtime/converter.cs +++ b/src/runtime/converter.cs @@ -28,7 +28,6 @@ private Converter() private static Type flagsType; private static Type boolType; private static Type typeType; - private static IntPtr decimalCtor; private static IntPtr dateTimeCtor; private static IntPtr timeSpanCtor; private static IntPtr tzInfoCtor; @@ -48,15 +47,9 @@ static Converter() boolType = typeof(Boolean); typeType = typeof(Type); - IntPtr decimalMod = Runtime.PyImport_ImportModule("decimal"); - if (decimalMod == null) throw new PythonException(); - IntPtr dateTimeMod = Runtime.PyImport_ImportModule("datetime"); if (dateTimeMod == null) throw new PythonException(); - decimalCtor = Runtime.PyObject_GetAttrString(decimalMod, "Decimal"); - if (decimalCtor == null) throw new PythonException(); - dateTimeCtor = Runtime.PyObject_GetAttrString(dateTimeMod, "datetime"); if (dateTimeCtor == null) throw new PythonException(); @@ -280,14 +273,9 @@ internal static IntPtr ToPython(object value, Type type) return Runtime.PyLong_FromUnsignedLongLong((ulong)value); case TypeCode.Decimal: - string d2s = ((decimal)value).ToString(nfi); - IntPtr d2p = Runtime.PyString_FromString(d2s); - IntPtr decimalArgs = Runtime.PyTuple_New(1); - Runtime.PyTuple_SetItem(decimalArgs, 0, d2p); - var returnDecimal = Runtime.PyObject_CallObject(decimalCtor, decimalArgs); - // clean up - Runtime.XDecref(decimalArgs); - return returnDecimal; + // C# decimal to python decimal has a big impact on performance + // so we will use C# double and python float + return Runtime.PyFloat_FromDouble(decimal.ToDouble((decimal) value)); case TypeCode.DateTime: var datetime = (DateTime)value; diff --git a/src/runtime/resources/clr.py b/src/runtime/resources/clr.py index 7217f98d1..7caff08f4 100644 --- a/src/runtime/resources/clr.py +++ b/src/runtime/resources/clr.py @@ -2,7 +2,7 @@ Code in this module gets loaded into the main clr module. """ -__version__ = "1.0.5.12" +__version__ = "1.0.5.13" class clrproperty(object):