8000 Performance improvements ClrObject - Dispose PyObj by Martin-Molinero · Pull Request #22 · QuantConnect/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Performance improvements ClrObject - Dispose PyObj #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.5.13
current_version = 1.0.5.14
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: pythonnet
version: "1.0.5.13"
version: "1.0.5.14"

build:
skip: True # [not win]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
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.13",
version="1.0.5.14",
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
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.13")]
[assembly: AssemblyVersion("1.0.5.14")]
2 changes: 1 addition & 1 deletion src/clrmodule/ClrModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void initclr()
{
#if USE_PYTHON_RUNTIME_VERSION
// Has no effect until SNK works. Keep updated anyways.
Version = new Version("1.0.5.12"),
Version = new Version("1.0.5.14"),
#endif
CultureInfo = CultureInfo.InvariantCulture
};
Expand Down
12 changes: 8 additions & 4 deletions src/runtime/clrobject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;

namespace Python.Runtime
Expand Down Expand Up @@ -29,9 +29,13 @@ internal CLRObject(object ob, IntPtr tp)
gcHandle = gc;
inst = ob;

// Fix the BaseException args (and __cause__ in case of Python 3)
// slot if wrapping a CLR exception
Exceptions.SetArgsAndCause(py);
// for performance before calling SetArgsAndCause() lets check if we are an exception
if (inst is Exception)
{
// Fix the BaseException args (and __cause__ in case of Python 3)
// slot if wrapping a CLR exception
Exceptions.SetArgsAndCause(py);
}
}


Expand Down
19 changes: 18 additions & 1 deletion src/runtime/pyobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public object AsManagedObject(Type t)
}
return result;
}

/// <summary>
/// As Method
/// </summary>
Expand Down Expand Up @@ -156,6 +156,23 @@ public void Dispose()
GC.SuppressFinalize(this);
}

/// <summary>
/// Unsafe Dispose Method.
/// To be used when already owning the GIL lock. <see cref="Dispose()"/>
/// </summary>
public void UnsafeDispose()
{
if (!disposed)
{
if (!Runtime.IsFinalizing)
{
Runtime.XDecref(obj);
obj = IntPtr.Zero;
}
disposed = true;
}
GC.SuppressFinalize(this);
}

/// <summary>
/// GetPythonType Method
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/resources/clr.py
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.13"
__version__ = "1.0.5.14"


class clrproperty(object):
Expand Down
0