23. Milhões de testes por segundo
def t2():
for i in L:
if i == 1000000: break
<snip 18 identical lines>
if i == 1000000: break
80
70
60
50
40
69
30
20
10
7
11
16
Python-2.1
Python-2.3
Python-2.4
15
21
0
IronPython on IronPython on IronPython on
1.1
2.0
2.0 w/opt
23
29. Adding Dynamic to .NET
IronPython
IronRuby
C#
VB.NET
Others…
Dynamic Language Runtime
Expression Trees
Object
Binder
JavaScript
Binder
Dynamic Dispatch
Python
Binder
Call Site Caching
Ruby
Binder
COM
Binder
29
30. IronPython Consumindo C#
public class Calculator {
…
public int Add(int x, int y) {
return x + y;
}
}
class Calculator:
…
def Add(self, x, y):
return x + y
calc = GetCalculator()
sum = calc.Add(10, 20)
30
31. C# 3.0 Consumindo IronPython
public class Calculator {
…
public int Add(int x, int y) {
return x + y;
}
}
class Calculator:
…
def Add(self, x, y):
return x + y
PyObject calc = GetCalculator();
Calculator calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20);
int sum = calc.Add(10, 20);
int sum = Convert.ToInt32(res);
object calc = GetCalculator();
Type calcType = calc.GetType();
object res = calcType.InvokeMember("Add",
BindingFlags.InvokeMethod, null,
new object[] { 10, 20 });
int sum = Convert.ToInt32(res);
31