1
1
#!/usr/bin/env python
2
2
# -*- coding: UTF-8 -*-
3
3
4
- #Copyright (c) 2012 Christian Schwarz
4
+ #Copyright (c) 2012-2013 Christian Schwarz
5
5
#
6
6
#Permission is hereby granted, free of charge, to any person obtaining
7
7
#a copy of this software and associated documentation files (the
21
21
#LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
22
#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
23
#WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
-
25
- from pycastobject import PyCastObject
26
-
27
24
def optimized (fn ):
28
25
"""Decorater that will call the optimized c++ version
29
26
of a pycast function if available rather than theo
@@ -46,15 +43,15 @@ def _optimized(self, *args, **kwargs):
46
43
:return result of the function call either from pycast or pycastC module.
47
44
:rtype: Function
48
45
"""
49
- if self .optimization_enabled :
46
+ if self .optimizationEnabled :
50
47
class_name = self .__class__ .__name__
51
- module = self .__module__ .replace (' pycast' , ' pycastC' )
48
+ module = self .__module__ .replace (" pycast" , " pycastC" )
52
49
try :
53
- imported = __import__ (module + "." + class_name , globals (), locals (), [fn .__name__ ])
50
+ imported = __import__ ("%s.%s" % ( module , class_name ) , globals (), locals (), [fn .__name__ ])
54
51
function = getattr (imported , fn .__name__ )
55
52
return function (self , * args , ** kwargs )
56
53
except ImportError :
57
- print "[WARNING] Could not enable optimization for %s, %s" % (fn .__name__ , self )
54
+ print "[WARNING] Could not enable optimization for %s, %s" % (fn .__name__ , self )
58
55
return fn (self , * args , ** kwargs )
59
56
else :
60
57
return fn (self , * args , ** kwargs )
0 commit comments