SlideShare a Scribd company logo
Santiago Paiva


Python's Class customization
 Better code



Solving cubic equations
 Difficult to design & test



Calculation on demand


Example: Cubic class
 Models cubic equations
 getRoots(): x1, x2, x3

ax  bx  cx  d
3

2

a , b, c , d  
a0
1  3c b 2 
f    2
3 a a 


g2 f 3
h

4 27
k 3 j
m  k

g
j

1  2b 3 9bc 27 d 


 2 
27  a 3
a
a 



x1

x2

x3

g2
h
4

 g 
l  arcsin  
 2j


l
n  cos 
3

s

b
l
p  3 sin  
q
3a
3
l  b 
x1  2k cos     x2  mn  p   q
 3   3a 
g
x3  mn  p   q
r  h
2
g
s3 r
t  h
2
b
u3 t
x1  s  u 
3a
su b
3i s  u 
su b
3i s  u 
x2  
 
x3  
 
2
3a
2
2
3a
2
d
x1  x 2  x3  3
a

u

q

r

p

n

t

l

h

k
j

f
a

m

b

g
c

d
import math
class Cubic:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def getRoots(self):
f = (3*self.c/self.a - self.b**2/self.a**2)/3

else:
i = ((g**2/4)-h)**0.5
j = i**(1/3)
k = math.acos(-(g/(2*i)))
m = math.cos(k/3)
n = math.sqrt(3) * math.sin(k/3)
p = -(self.b/(3*self.a))
x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a))
x2 = -j*(m+n)+p
x3 = -j*(m-n)+p
return x1, x2, x3

g = (2*self.b**3/self.a**3 
9*self.b*self.c/self.a**2 
+ 27*self.d/self.a)/27
h = g**2/4 + f**3/27
if f == 0 and g == 0 and h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif h > 0:
r = -(g/2) + h**0.5
if r < 0:
s = -abs(r)**(1/3)
else:
s = r**(1/3)
t = -(g/2) - h**0.5
if t < 0:
u = -abs(t)**(1/3)
else:
u = t**(1/3)
x1 = (s+u)-(self.b/(3*self.a))
x2 = complex(-(s+u)/2 - (self.b/(3*self.a)),
((s-u)*3**0.5)/2)
x3 = complex(-(s+u)/2 - (self.b/(3*self.a)),
-((s-u)*3**0.5)/2)

def printRoots(cubic):
for index, root in enumerate(cubic.getRoots()):
print("x{0}: {1}".format(index+1, root))
printRoots(Cubic(2, -4, -22, 24))
printRoots(Cubic(3, -10, 14, 27))
printRoots(Cubic(1,
6, 12, 8))
import math
class Cubic:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def getRoots(self):
f = (3*self.c/self.a - self.b**2/self.a**2)/3

else:
i = ((g**2/4)-h)**0.5
j = i**(1/3)
k = math.acos(-(g/(2*i)))
m = math.cos(k/3)
n = math.sqrt(3) * math.sin(k/3)
p = -(self.b/(3*self.a))
x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a))
x2 = -j*(m+n)+p
x3 = -j*(m-n)+p
return x1, x2, x3

g = (2*self.b**3/self.a**3 
9*self.b*self.c/self.a**2 
+ 27*self.d/self.a)/27
h = g**2/4 + f**3/27
if f == 0 and g == 0 and h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif h > 0:
r = -(g/2) + h**0.5
if r < 0:
s = -abs(r)**(1/3)
else:
s = r**(1/3)
t = -(g/2) - h**0.5
if t < 0:
u = -abs(t)**(1/3)
else:
u = t**(1/3)
x1 = (s+u)-(self.b/(3*self.a))
x2 = complex(-(s+u)/2 - (self.b/(3*self.a)),
((s-u)*3**0.5)/2)
x3 = complex(-(s+u)/2 - (self.b/(3*self.a)),
-((s-u)*3**0.5)/2)

def printRoots(cubic):
for index, root in enumerate(cubic.getRoots()):
print("x{0}: {1}".format(index+1, root))
printRoots(Cubic(2, -4, -22, 24))
printRoots(Cubic(3, -10, 14, 27))
printRoots(Cubic(1,
6, 12, 8))
import math
class Cubic:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def getRoots(self):
f = (3*self.c/self.a - self.b**2/self.a**2)/3

else:
i = ((g**2/4)-h)**0.5
j = i**(1/3)
k = math.acos(-(g/(2*i)))
m = math.cos(k/3)
n = math.sqrt(3) * math.sin(k/3)
p = -(self.b/(3*self.a))
x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a))
x2 = -j*(m+n)+p
x3 = -j*(m-n)+p
return x1, x2, x3

g = (2*self.b**3/self.a**3 
9*self.b*self.c/self.a**2 
+ 27*self.d/self.a)/27

self.calc_h()
h = g**2/4 + f**3/27
if f == 0 and g == 0 and h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif h > 0:
r = -(g/2) + h**0.5
if r < 0:
s = -abs(r)**(1/3)
else:
s = r**(1/3)
t = -(g/2) - h**0.5
if t < 0:
u = -abs(t)**(1/3)
else:
u = t**(1/3)
x1 = (s+u)-(self.b/(3*self.a))
x2 = complex(-(s+u)/2 - (self.b/(3*self.a)),
((s-u)*3**0.5)/2)
x3 = complex(-(s+u)/2 - (self.b/(3*self.a)),
-((s-u)*3**0.5)/2)

def printRoots(cubic):
for index, root in enumerate(cubic.getRoots()):
print("x{0}: {1}".format(index+1, root))
printRoots(Cubic(2, -4, -22, 24))
printRoots(Cubic(3, -10, 14, 27))
printRoots(Cubic(1,
6, 12, 8))
import math
class Cubic:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def _f(self):
self.f = (3*self.c/self.a - self.b**2/self.a**2)/3
def _g(self):
self.g = (2*self.b**3/self.a**3 - 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27
def _h(self):
self.h = self.g**2/4 + self.f**3/27
def _r(self):
self.r = -(self.g/2) + self.h**0.5
def _s(self):
self.s = -abs(self.r)**(1/3) if self.r < 0 else self.r**(1/3)
def _t(self):
self.t = -(self.g/2) - self.h**0.5

def _u(self):
self.u = -abs(self.t)**(1/3) if self.t < 0 else self.t**(1/3)
def _i(self):
self.i = ((self.g**2/4)-self.h)**0.5
def _j(self):
self.j = self.i**(1/3)
(ect...)
def getRoots(self):
f = (3*self.c/self.a - self.b**2/self.a**2)/3
g = (2*self.b**3/self.a**3 
9*self.b*self.c/self.a**2 
+ 27*self.d/self.a)/27
h = g**2/4 + f**3/27
if f == 0 and g == 0 and h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif h > 0:
r = -(g/2) + h**0.5
if r < 0:
s = -abs(r)**(1/3)
else:
s = r**(1/3)
t = -(g/2) - h**0.5
if t < 0:
u = -abs(t)**(1/3)
else:
u = t**(1/3)
x1 = (s+u)-(self.b/(3*self.a))
x2 = complex(-(s+u)/2 - (self.b/(3*self.a)),
((s-u)*3**0.5)/2)
x3 = complex(-(s+u)/2 - (self.b/(3*self.a)),
-((s-u)*3**0.5)/2)
else:
i = ((g**2/4)-h)**0.5
j = i**(1/3)
k = math.acos(-(g/(2*i)))
m = math.cos(k/3)
n = math.sqrt(3) * math.sin(k/3)
p = -(self.b/(3*self.a))
x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a))
x2 = -j*(m+n)+p
x3 = -j*(m-n)+p
return x1, x2, x3
def getRoots(self):
self._f()
self._g()
self._h()
if self.f == 0 and self.g == 0 and self.h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif self.h > 0:
self._r()
self._s()
self._t()
self._u()
x1 = (self.s+self.u)-(self.b/(3*self.a))
x2 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)),
((self.s-self.u)*3**0.5)/2)
x3 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)),
-((self.s-self.u)*3**0.5)/2)
else:
self._i()
self._j()
self._k()
self._m()
self._n()
self._p()
x1 = 2*self.j*math.cos(self.k/3)-(self.b/(3*self.a))
x2 = -self.j*(self.m+self.n)+self.p
x3 = -self.j*(self.m-self.n)+self.p
return x1, x2, x3


Special method

def myMethod(self):
return self.a

 __getattr__

Called when variable
not found
 Passed unfound
variable name
 Returns an appropriate
value
 Raises AttributeError


__getattr__
def getRoots(self):
self._f()
self._g()
self._h()
if self.f == 0 and self.g == 0 and self.h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif self.h > 0:
self._r()
self._s()
self._t()
self._u()
x1 = (self.s+self.u)-(self.b/(3*self.a))
x2 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)),
((self.s-self.u)*3**0.5)/2)
x3 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)),
-((self.s-self.u)*3**0.5)/2)
else:
self._i()
self._j()
self._k()
self._m()
self._n()
self._p()
x1 = 2*self.j*math.cos(self.k/3)-(self.b/(3*self.a))
x2 = -self.j*(self.m+self.n)+self.p
x3 = -self.j*(self.m-self.n)+self.p
return x1, x2, x3
def getRoots(self):
if self.f == 0 and self.g == 0 and self.h == 0:
x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3
elif self.h > 0:
x1 = (self.s+self.u)-(self.b/(3*self.a))
x2 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)),
((self.s-self.u)*3**0.5)/2)
x3 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)),
-((self.s-self.u)*3**0.5)/2)

else:
x1 = 2*self.j*math.cos(self.k/3)-(self.b/(3*self.a))
x2 = -self.j*(self.m+self.n)+self.p
x3 = -self.j*(self.m-self.n)+self.p
return x1, x2, x3
import math
class Cubic:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d

def __getattr__(self, name):
calcName = "_" + name
if hasattr(self, calcName):
getattr(self, calcName)()
return getattr(self, name)
else:
raise AttributeError
def _f(self):
self.f = (3*self.c/self.a - self.b**2/self.a**2)/3
def _g(self):
self.g = (2*self.b**3/self.a**3 - 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27
def _h(self):
self.h = self.g**2/4 + self.f**3/27
def _r(self):
self.r = -(self.g/2) + self.h**0.5
def _s(self):
self.s = -abs(self.r)**(1/3) if self.r < 0 else self.r**(1/3)
__getattr__:
__getattr__:
__getattr__:
__getattr__:
__getattr__:
__getattr__:
__getattr__:
__getattr__:
__getattr__:
x1: 4.0
x2: -3.0
x3: 1.0

f
h
g
j
i
k
m
n
p

__getattr__: f
__getattr__: h

__getattr__:
__getattr__:
__getattr__:
__getattr__:
__getattr__:
x1: -1.0

g
s
r
u
t

x2: (2.16666666667+2.07498326633j)
x3: (2.16666666667-2.07498326633j)

__getattr__: f
__getattr__: g
__getattr__: h
x1: -2.0
x2: -2.0
x3: -2.0


Elliptic Curves Crypto-Systems
 Improved testability
 Clearer code


Discrete calculation methods
 Improved testability
 Clearer code





Class customization
Implemented calculation on demand
Do not worry evaluation order
 Faster, more reliable design & implementation



Easier code modification
 Calculation order automatically changes


Sutton, Peter. ”Advanced Python, Better
Code”. The University of Manchester, 2009.


Slides:



Code: https://github.com/paiva/cubic



Presentation:



Say ‘Hi’ on Twitter: @Stronnics



Enjoy the rest of the conference !

More Related Content

What's hot

MATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIES
MATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIESMATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIES
MATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIES
Ist. Superiore Marini-Gioia - Enzo Exposyto
 
4.1 inverse functions t
4.1 inverse functions t4.1 inverse functions t
4.1 inverse functions t
math260
 
Creating a Table from a Function
Creating a Table from a FunctionCreating a Table from a Function
Creating a Table from a Function
dmidgette
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
KristhyanAndreeKurtL
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
Dr. Volkan OBAN
 
Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''
OdessaJS Conf
 
graphs plotting in MATLAB
graphs plotting in MATLABgraphs plotting in MATLAB
graphs plotting in MATLAB
Apurva Patil
 
Mosaic plot in R.
Mosaic plot in R.Mosaic plot in R.
Mosaic plot in R.
Dr. Volkan OBAN
 
Lambda calculus
Lambda calculusLambda calculus
Lambda calculus
Attila Magyar
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
Dr. Volkan OBAN
 
Math for 800 09 functions
Math for 800   09 functionsMath for 800   09 functions
Math for 800 09 functions
Edwin Lapuerta
 
Ch18 18
Ch18 18Ch18 18
Ch18 18
schibu20
 
Composicion de funciones
Composicion de funcionesComposicion de funciones
Composicion de funciones
Paito Sarauz
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
jesquerrev1
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
jesquerrev1
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
shahid sultan
 
Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018
Timur Shemsedinov
 
Grph quad fncts
Grph quad fnctsGrph quad fncts
Grph quad fncts
Edrian Gustin Camacho
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
Dr. Volkan OBAN
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
Dr. Volkan OBAN
 

What's hot (20)

MATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIES
MATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIESMATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIES
MATHS SYMBOLS - EXPONENTIALS + LOGARITHMS and THEIR PROPERTIES
 
4.1 inverse functions t
4.1 inverse functions t4.1 inverse functions t
4.1 inverse functions t
 
Creating a Table from a Function
Creating a Table from a FunctionCreating a Table from a Function
Creating a Table from a Function
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''
 
graphs plotting in MATLAB
graphs plotting in MATLABgraphs plotting in MATLAB
graphs plotting in MATLAB
 
Mosaic plot in R.
Mosaic plot in R.Mosaic plot in R.
Mosaic plot in R.
 
Lambda calculus
Lambda calculusLambda calculus
Lambda calculus
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
 
Math for 800 09 functions
Math for 800   09 functionsMath for 800   09 functions
Math for 800 09 functions
 
Ch18 18
Ch18 18Ch18 18
Ch18 18
 
Composicion de funciones
Composicion de funcionesComposicion de funciones
Composicion de funciones
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018
 
Grph quad fncts
Grph quad fnctsGrph quad fncts
Grph quad fncts
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
 

Similar to Class Customization and Better Code

Turning Point of the Pokemon Battle. pptx
Turning Point of the  Pokemon Battle. pptxTurning Point of the  Pokemon Battle. pptx
Turning Point of the Pokemon Battle. pptx
PatrickMaravilla1
 
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in MatlabMathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in Matlab
COMSATS Abbottabad
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturial
Wayne Tsai
 
Software Visualization 101+
Software Visualization 101+Software Visualization 101+
Software Visualization 101+
Michele Lanza
 
functions limits and continuity
functions limits and continuityfunctions limits and continuity
functions limits and continuity
Pume Ananda
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
Ke Wei Louis
 
Oh Composable World!
Oh Composable World!Oh Composable World!
Oh Composable World!
Brian Lonsdorf
 
Respuestas de la prueba parcial n. 2-matlab
Respuestas de la prueba parcial n. 2-matlabRespuestas de la prueba parcial n. 2-matlab
Respuestas de la prueba parcial n. 2-matlab
fabriciovillacres2017
 
Functions limits and continuity
Functions limits and continuityFunctions limits and continuity
Functions limits and continuity
sudersana viswanathan
 
Solutions manual for calculus an applied approach brief international metric ...
Solutions manual for calculus an applied approach brief international metric ...Solutions manual for calculus an applied approach brief international metric ...
Solutions manual for calculus an applied approach brief international metric ...
Larson612
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
hyacinthshackley2629
 
Pybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonPybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in Python
Christoph Matthies
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
ikdysfm
 
Py3k
Py3kPy3k
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
Yung-Yu Chen
 
Modul 1 functions
Modul 1 functionsModul 1 functions
Modul 1 functions
Norelyana Ali
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
Simone Federici
 

Similar to Class Customization and Better Code (17)

Turning Point of the Pokemon Battle. pptx
Turning Point of the  Pokemon Battle. pptxTurning Point of the  Pokemon Battle. pptx
Turning Point of the Pokemon Battle. pptx
 
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in MatlabMathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electro-Mechanical System in Matlab
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturial
 
Software Visualization 101+
Software Visualization 101+Software Visualization 101+
Software Visualization 101+
 
functions limits and continuity
functions limits and continuityfunctions limits and continuity
functions limits and continuity
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Oh Composable World!
Oh Composable World!Oh Composable World!
Oh Composable World!
 
Respuestas de la prueba parcial n. 2-matlab
Respuestas de la prueba parcial n. 2-matlabRespuestas de la prueba parcial n. 2-matlab
Respuestas de la prueba parcial n. 2-matlab
 
Functions limits and continuity
Functions limits and continuityFunctions limits and continuity
Functions limits and continuity
 
Solutions manual for calculus an applied approach brief international metric ...
Solutions manual for calculus an applied approach brief international metric ...Solutions manual for calculus an applied approach brief international metric ...
Solutions manual for calculus an applied approach brief international metric ...
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
 
Pybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in PythonPybelsberg — Constraint-based Programming in Python
Pybelsberg — Constraint-based Programming in Python
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Py3k
Py3kPy3k
Py3k
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
Modul 1 functions
Modul 1 functionsModul 1 functions
Modul 1 functions
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 

Recently uploaded

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 

Recently uploaded (20)

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 

Class Customization and Better Code

  • 1.
  • 2.
  • 4.  Python's Class customization  Better code  Solving cubic equations  Difficult to design & test  Calculation on demand
  • 5.  Example: Cubic class  Models cubic equations  getRoots(): x1, x2, x3 ax  bx  cx  d 3 2 a , b, c , d   a0
  • 6. 1  3c b 2  f    2 3 a a    g2 f 3 h  4 27 k 3 j m  k g j 1  2b 3 9bc 27 d     2  27  a 3 a a    x1 x2 x3 g2 h 4  g  l  arcsin    2j   l n  cos  3 s b l p  3 sin   q 3a 3 l  b  x1  2k cos     x2  mn  p   q  3   3a  g x3  mn  p   q r  h 2 g s3 r t  h 2 b u3 t x1  s  u  3a su b 3i s  u  su b 3i s  u  x2     x3     2 3a 2 2 3a 2 d x1  x 2  x3  3 a u q r p n t l h k j f a m b g c d
  • 7. import math class Cubic: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def getRoots(self): f = (3*self.c/self.a - self.b**2/self.a**2)/3 else: i = ((g**2/4)-h)**0.5 j = i**(1/3) k = math.acos(-(g/(2*i))) m = math.cos(k/3) n = math.sqrt(3) * math.sin(k/3) p = -(self.b/(3*self.a)) x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a)) x2 = -j*(m+n)+p x3 = -j*(m-n)+p return x1, x2, x3 g = (2*self.b**3/self.a**3 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27 h = g**2/4 + f**3/27 if f == 0 and g == 0 and h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif h > 0: r = -(g/2) + h**0.5 if r < 0: s = -abs(r)**(1/3) else: s = r**(1/3) t = -(g/2) - h**0.5 if t < 0: u = -abs(t)**(1/3) else: u = t**(1/3) x1 = (s+u)-(self.b/(3*self.a)) x2 = complex(-(s+u)/2 - (self.b/(3*self.a)), ((s-u)*3**0.5)/2) x3 = complex(-(s+u)/2 - (self.b/(3*self.a)), -((s-u)*3**0.5)/2) def printRoots(cubic): for index, root in enumerate(cubic.getRoots()): print("x{0}: {1}".format(index+1, root)) printRoots(Cubic(2, -4, -22, 24)) printRoots(Cubic(3, -10, 14, 27)) printRoots(Cubic(1, 6, 12, 8))
  • 8. import math class Cubic: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def getRoots(self): f = (3*self.c/self.a - self.b**2/self.a**2)/3 else: i = ((g**2/4)-h)**0.5 j = i**(1/3) k = math.acos(-(g/(2*i))) m = math.cos(k/3) n = math.sqrt(3) * math.sin(k/3) p = -(self.b/(3*self.a)) x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a)) x2 = -j*(m+n)+p x3 = -j*(m-n)+p return x1, x2, x3 g = (2*self.b**3/self.a**3 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27 h = g**2/4 + f**3/27 if f == 0 and g == 0 and h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif h > 0: r = -(g/2) + h**0.5 if r < 0: s = -abs(r)**(1/3) else: s = r**(1/3) t = -(g/2) - h**0.5 if t < 0: u = -abs(t)**(1/3) else: u = t**(1/3) x1 = (s+u)-(self.b/(3*self.a)) x2 = complex(-(s+u)/2 - (self.b/(3*self.a)), ((s-u)*3**0.5)/2) x3 = complex(-(s+u)/2 - (self.b/(3*self.a)), -((s-u)*3**0.5)/2) def printRoots(cubic): for index, root in enumerate(cubic.getRoots()): print("x{0}: {1}".format(index+1, root)) printRoots(Cubic(2, -4, -22, 24)) printRoots(Cubic(3, -10, 14, 27)) printRoots(Cubic(1, 6, 12, 8))
  • 9. import math class Cubic: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def getRoots(self): f = (3*self.c/self.a - self.b**2/self.a**2)/3 else: i = ((g**2/4)-h)**0.5 j = i**(1/3) k = math.acos(-(g/(2*i))) m = math.cos(k/3) n = math.sqrt(3) * math.sin(k/3) p = -(self.b/(3*self.a)) x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a)) x2 = -j*(m+n)+p x3 = -j*(m-n)+p return x1, x2, x3 g = (2*self.b**3/self.a**3 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27 self.calc_h() h = g**2/4 + f**3/27 if f == 0 and g == 0 and h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif h > 0: r = -(g/2) + h**0.5 if r < 0: s = -abs(r)**(1/3) else: s = r**(1/3) t = -(g/2) - h**0.5 if t < 0: u = -abs(t)**(1/3) else: u = t**(1/3) x1 = (s+u)-(self.b/(3*self.a)) x2 = complex(-(s+u)/2 - (self.b/(3*self.a)), ((s-u)*3**0.5)/2) x3 = complex(-(s+u)/2 - (self.b/(3*self.a)), -((s-u)*3**0.5)/2) def printRoots(cubic): for index, root in enumerate(cubic.getRoots()): print("x{0}: {1}".format(index+1, root)) printRoots(Cubic(2, -4, -22, 24)) printRoots(Cubic(3, -10, 14, 27)) printRoots(Cubic(1, 6, 12, 8))
  • 10. import math class Cubic: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def _f(self): self.f = (3*self.c/self.a - self.b**2/self.a**2)/3 def _g(self): self.g = (2*self.b**3/self.a**3 - 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27 def _h(self): self.h = self.g**2/4 + self.f**3/27 def _r(self): self.r = -(self.g/2) + self.h**0.5 def _s(self): self.s = -abs(self.r)**(1/3) if self.r < 0 else self.r**(1/3) def _t(self): self.t = -(self.g/2) - self.h**0.5 def _u(self): self.u = -abs(self.t)**(1/3) if self.t < 0 else self.t**(1/3) def _i(self): self.i = ((self.g**2/4)-self.h)**0.5 def _j(self): self.j = self.i**(1/3) (ect...)
  • 11. def getRoots(self): f = (3*self.c/self.a - self.b**2/self.a**2)/3 g = (2*self.b**3/self.a**3 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27 h = g**2/4 + f**3/27 if f == 0 and g == 0 and h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif h > 0: r = -(g/2) + h**0.5 if r < 0: s = -abs(r)**(1/3) else: s = r**(1/3) t = -(g/2) - h**0.5 if t < 0: u = -abs(t)**(1/3) else: u = t**(1/3) x1 = (s+u)-(self.b/(3*self.a)) x2 = complex(-(s+u)/2 - (self.b/(3*self.a)), ((s-u)*3**0.5)/2) x3 = complex(-(s+u)/2 - (self.b/(3*self.a)), -((s-u)*3**0.5)/2) else: i = ((g**2/4)-h)**0.5 j = i**(1/3) k = math.acos(-(g/(2*i))) m = math.cos(k/3) n = math.sqrt(3) * math.sin(k/3) p = -(self.b/(3*self.a)) x1 = 2*j*math.cos(k/3)-(self.b/(3*self.a)) x2 = -j*(m+n)+p x3 = -j*(m-n)+p return x1, x2, x3
  • 12. def getRoots(self): self._f() self._g() self._h() if self.f == 0 and self.g == 0 and self.h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif self.h > 0: self._r() self._s() self._t() self._u() x1 = (self.s+self.u)-(self.b/(3*self.a)) x2 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)), ((self.s-self.u)*3**0.5)/2) x3 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)), -((self.s-self.u)*3**0.5)/2) else: self._i() self._j() self._k() self._m() self._n() self._p() x1 = 2*self.j*math.cos(self.k/3)-(self.b/(3*self.a)) x2 = -self.j*(self.m+self.n)+self.p x3 = -self.j*(self.m-self.n)+self.p return x1, x2, x3
  • 13.  Special method def myMethod(self): return self.a  __getattr__ Called when variable not found  Passed unfound variable name  Returns an appropriate value  Raises AttributeError  __getattr__
  • 14. def getRoots(self): self._f() self._g() self._h() if self.f == 0 and self.g == 0 and self.h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif self.h > 0: self._r() self._s() self._t() self._u() x1 = (self.s+self.u)-(self.b/(3*self.a)) x2 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)), ((self.s-self.u)*3**0.5)/2) x3 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)), -((self.s-self.u)*3**0.5)/2) else: self._i() self._j() self._k() self._m() self._n() self._p() x1 = 2*self.j*math.cos(self.k/3)-(self.b/(3*self.a)) x2 = -self.j*(self.m+self.n)+self.p x3 = -self.j*(self.m-self.n)+self.p return x1, x2, x3
  • 15. def getRoots(self): if self.f == 0 and self.g == 0 and self.h == 0: x1, x2, x3 = [-(self.d/self.a)**(1/3)]*3 elif self.h > 0: x1 = (self.s+self.u)-(self.b/(3*self.a)) x2 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)), ((self.s-self.u)*3**0.5)/2) x3 = complex(-(self.s+self.u)/2 - (self.b/(3*self.a)), -((self.s-self.u)*3**0.5)/2) else: x1 = 2*self.j*math.cos(self.k/3)-(self.b/(3*self.a)) x2 = -self.j*(self.m+self.n)+self.p x3 = -self.j*(self.m-self.n)+self.p return x1, x2, x3
  • 16. import math class Cubic: def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def __getattr__(self, name): calcName = "_" + name if hasattr(self, calcName): getattr(self, calcName)() return getattr(self, name) else: raise AttributeError def _f(self): self.f = (3*self.c/self.a - self.b**2/self.a**2)/3 def _g(self): self.g = (2*self.b**3/self.a**3 - 9*self.b*self.c/self.a**2 + 27*self.d/self.a)/27 def _h(self): self.h = self.g**2/4 + self.f**3/27 def _r(self): self.r = -(self.g/2) + self.h**0.5 def _s(self): self.s = -abs(self.r)**(1/3) if self.r < 0 else self.r**(1/3)
  • 17. __getattr__: __getattr__: __getattr__: __getattr__: __getattr__: __getattr__: __getattr__: __getattr__: __getattr__: x1: 4.0 x2: -3.0 x3: 1.0 f h g j i k m n p __getattr__: f __getattr__: h __getattr__: __getattr__: __getattr__: __getattr__: __getattr__: x1: -1.0 g s r u t x2: (2.16666666667+2.07498326633j) x3: (2.16666666667-2.07498326633j) __getattr__: f __getattr__: g __getattr__: h x1: -2.0 x2: -2.0 x3: -2.0
  • 18.  Elliptic Curves Crypto-Systems  Improved testability  Clearer code
  • 19.  Discrete calculation methods  Improved testability  Clearer code    Class customization Implemented calculation on demand Do not worry evaluation order  Faster, more reliable design & implementation  Easier code modification  Calculation order automatically changes
  • 20.  Sutton, Peter. ”Advanced Python, Better Code”. The University of Manchester, 2009.
  • 21.  Slides:  Code: https://github.com/paiva/cubic  Presentation:  Say ‘Hi’ on Twitter: @Stronnics  Enjoy the rest of the conference !