FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

C# decimal to Python conversion by Martin-Molinero · Pull Request #19 · QuantConnect/pythonnet · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cfg  (1) .cs  (2) .py  (2) .yaml  (1) All 4 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion .bumpversion.cfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.5.12
current_version = 1.0.5.13
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
serialize =
{major}.{minor}.{patch}.{release}{dev}
Expand Down
2 changes: 1 addition & 1 deletion conda.recipe/meta.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: pythonnet
version: "1.0.5.12"
version: "1.0.5.13"

build:
skip: True # [not win]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/SharedAssemblyInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
18 changes: 3 additions & 15 deletions src/runtime/converter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/resources/clr.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

Back | FazBrowse Home | New Git URL