►
Description
This presentation was the first experiment with livestreaming of the Rust Zürisee meetup group in Switzerland.
Gerhard is sharing parts of his story migrating Pascal code from a research paper to a Rust module usable from Python.
How he was able to use Rust to improve the Python and C code to be included in a LCA software by Sustainable System Solutions (an ETH spinn-off) preventing segfaults while keeping up with the speed of the C solution.
https://www.meetup.com/Rust-Zurich/events/269771239/
A
Hello,
hello
hope
this
works.
Yes,
hello,
everybody.welcome,
checking
that
the
sound
loops-
true
yes,
that
works
so
welcome
to
our
very
first
pure
online
rust
Mita
from
Zurich.
You
might
be
wondering
why
I'm
not
always
talking
to
you.
That's
because
I
have
this
set
up
all
over
the
place,
my
control
station
main
monitor
and
the
camera
from
the
laptop.
So
how
are
we
going
to
do
this?
As
you
all,
probably
seen
in
the
comments
on
meetup.com
or
on
the
life
started?
Ch
website
we
have
a
matrix
channel.
A
It's
the
same
idea.
You
have
just
a
browser
and
it
should
work.
We
tested
the
solution
with
jitsi
and
we
initially
wanted
to
run
with
it.
However,
we
noticed
that,
after
like
20
ish
clients,
23
8
clients,
especially
the
some
of
them,
have
mobile
phone
sorry,
some
people
use
mobile
phone.
Then
it
gets
really
laggy
and
messes
up
a
whole
configuration.
So
that's
why
we
decided
against
it,
and
now
we
use
this
setup.
So
how
do
we
work
currently?
A
What
you're
seeing
is
VLC
grabbing
my
webcam
streaming
it
all
over
to
the
Internet
Danilo
he's
our
operator
tonight.
The
lineal
also
connects
the
video
signal
from
Gerhart,
our
speaker
and
his
slides,
and
once
everything
is
together,
he
streams.
It
then
to
the
next
network,
in
this
case
twitch,
which,
when
I
checked
back
here,
I
heard
34:45,
four
or
five
people
are
already
watching,
which
is
very
good.
A
A
Thank
you
very
much
wonderful.
So,
as
you
see,
this
is
Gerhardt.
So
computer
engineer
enthusiast
it
lots
of
experience.
Can
you
hear
me
get
up?
Yes,
I
can
hear
you
wonderful
to
check
if
the
screen-
yes,
wonderful,
we
are
all
set
up.
So
as
before
used
is
the
matrix
chapter
see
some
questions
are
coming
up
already.
A
B
Thanks
Stefan
for
the
introduction
and
welcome
everybody
to
my
talk,
so
I'm
Carrie
I
am
currently
the
research
platform
developer
at
SAS
scientific
IT
service
services
at
ETH.
In
my
former
job,
I
was
employed
at
sustainable
system
solutions.
That's
where
the
the
current
talk
has
its
origins.
So
the
use
case
I'm
going
to
show
you
today
is
a
simulation
of
a
downhaul
heat
exchanger.
B
So
what
is
a
downhaul
heat?
Exchanger
I
I
have
made
a
picture
that
for
those
who
don't
know
what
that
is
so
for
later,
I
quickly
give
some
important
names
of
the
things
here.
So
the
red
line
going
down
I
will
be
refer
that
to
the
temperature
of
the
sink
and
the
blue
that
the
temperature
of
the
fluid
also
called
brine,
which
is
coming
up,
is
then
the
source.
B
B
So
the
goal
here
was
to
refactor
that
software,
so
that
it
could
be
used
in
a
life
cycle
analysis
software
written
in
Python,
so
I
went
there
and
started
to
port
this
code,
which
was
available
on
in
in
some
PDF
at
their
home
page
and
started
to
write
the
code
in
rewrite
the
code
in
Python.
So
what
should
this
program
do
as.
B
You
give
some
material
properties
the
depth
of
pipes
going
down.
Then
you
either
give
the
temperature
in
function
of
the
time.
All
you
give
the
power
in
in
function
of
the
time.
At
the
sink
and
as
an
output,
you
should
get
the
temperature
distribution
of
the
whole
soil
surrounding
the
downhaul
heat
exchanger,
as
well
also
as
the
temperature
of
the
brine
itself
moved
on
yeah.
B
So
how
is
this?
How
is
the
numerix
of
the
software
done?
So,
of
course
you
need
some
discretization
of
the
parts,
and
here
you
can
see
a
quick
overview
of
the
whole
thing
and
the
region
is
divided
in
basically
three
main
domains.
The
innermost
domain
is
the
pipes
going
down
and
coming
up
the
gray
pipes.
You
see
here
then
a
little
bit
an
outer
cylinder
composed
of
some
shells
of
soil.
B
As
you
can
see
these
circles,
you
can
see
here
and
then
the
outer
part
is
just
an
outer
region
and
the
simulation
is
really
done
like
this.
You
have
also
three
times
Cales
the
on
the
highest
frequency.
The
the
pipes
in
the
middle
will
be
refreshed
and
computed,
and
after
some
repetitions
on
some
iteration
of
that,
you
go
one
step
to
the
out
outer
part
to
the
earth
cylinder,
and
then
you
recompute
the
temperatures
in
in
there
and
as
a
final
step,
you
can.
B
You
can
compute
how
much
energy
you
you
drained
from
from
these
pipes
and
with
the
aid
of
the
heat
equation.
You
can
then
compute
the
temperature
at
the
boundary,
which
is
then
represented
by
this
outer
region.
Here,
as
you
can
see,
the
the
single
parts
are
subdivided,
so
the
pipe
is,
as
you
in
this
example
is
divided
into
three
CEO
parts,
and
so
is
also
the
earth,
the
the
soil
layers,
and
then
you
also
have
radial
division
into
into
also
three
powers
here.
Okay,
and
most
importantly,
you
also
can
see
various
the
crap
here,
good.
B
So
here
is
the
is
connection,
can
see
the
original
Pascal
code.
As
you
can
see,
it
looks
like
a
little
bit
spaghetti.
There
are
a
lot
of
different
things
which
go
together
in
one
big
function:
they
they
have
a
distinction
that
it
is
a
coaxial,
axial
down
whole
exchanger
or
or
not,
and
then
they
have
another
case
distinction.
If,
if
you
want
to
compute
stationary
or
you
want
to
compute
dynamic,
so
yeah
took
quite
a
time
to
refactor
all
that
code
and
it
went
into
this
Python
core
come
here.
B
B
B
Really
so
I
mean
it
felt
like
my
CPU
after
three
days
of
a
painful
computing,
my
CPU
died,
but
no
choking
it.
It
just
took
ages
to
compute
and
number
number
is
not
a
brain
here.
It's
just
these
four
loops
which
I
didn't
vectorize
out
here,
so
I
thought
about
her.
So
how
can
I
increase
the
performance
and
I
was
thinking?
How
can
I
vectorize
out
these
four
loops.
B
So,
let's
see,
let's
have
a
look
at
the
structure
of
the
innermost
for
loop.
The
innermost
for
loop
does
the
following.
So
you
have
you
have?
Basically,
if
you
remember
this
picture
with
the
pipes
going
down
and
up
what
you
see
here
is
T
I
represent
the
temperatures
of
the
single
segments
of
the
pipes
and
then
to
go
from
one
time
step
to
the
next.
B
B
B
Some
function,
which
would
to
solve
such
recursively
defined
sequence,
but
what
you
can
do
with
SIA
is
you?
Can
you
can
see
that
the
above
system
of
equations
can
be
rewritten
in
this
matrix
equation
here?
Where
you
basically
have
the
left
hand?
Side
is
a
matrix
a
times
a
vector,
T
prime,
compare
which,
which
contains
all
the
components
di
and
the
right-hand
side
is
just
another.
A
B
Which
is
which
depends
on
the
previous
vector
team,
so
the
funny
thing
here
is
this
matrix
is
just
bye-bye
diagonal,
so
you
have
to
solve
a
bit
diagonal
matrix
system
this.
That
means
you
are
you
have
order
n?
Instead
of
order
n
square,
when
you
have
an
ordinary
metric
matrix
which
is
not
sparse
and
you,
then
it
costs
you
and
square
computations
when,
if
n
is
the
size
of
the
matrix
here,
if
it's
be
diagonal,
you
only
have
at
the
end.
So
that's
that's
nice.
So
we
could.
B
We
could
vectorize
the
inner
for
loop
like
this,
but
still
we
have
the
outer
for
loop
and
the
second
for
the
second
for
loop.
If
you
have
a
look
at
the
code-
and
you
see
it's
just
a
wrapper,
simple
repetition
as
a
number
of
iterations
and
then
you
you
can
apply
this
matrix
several
times
and
times.
If
you
want,
you
can
then
exchange
the
exponents
and
then
you
will
see
you
just
have
to
solve
a
lower
diagonal
matrix
system.
A
B
B
B
But
when
it
comes
to
the
interface
to
Python,
you
see
that
you
can
half
the
size
of
the
code.
That's
just
the
extension
part,
not
not
the
numeric
part,
and
you
have
me
near
see
performance
and,
of
course
you
have
rust
developing
experience
without
these
nasty
seg
faults
and
as
a
as
a
remark
here,
you
still,
of
course
you
still
can
have
some
indexing
errors.
B
Memory
errors
went
went
away,
so
I
was
very
happy
with
that
before
I
come
to
the
benchmarks
which
I
want
to
show
you
a
comparison
on.
My
own
laptop
here,
I
want
to
show
you
such
what
what
what
an
output
is
like
so
I
basically
ran
over
one
year.
I
gave
some
input.
The
input
was
is
basically
the
yellow
part
in
the
bottom
and
the
left-hand
side.
You
can't
see
it
very
well
because
it's
it's
turning
on
and
off
so
so
frequently
that
I
had
I
also
provide
right-hand
side.
Where
you
can.
B
B
B
B
What
I
can
get
out
of
rust,
so
I
thought
about
optimizing,
this
innermost
for
loop
a
little
bit,
and
so
basically,
what
I
did
is
the
what
I
had
before
is
I
had
this
problem
in,
in
which
I
every
time,
access
the
eighth
element
and
the
preceding
element
as
well,
and
then
I
thought
what,
if
I
cash
this
one
of
those,
so
that
I
don't
have
to
access
to
elements
of
the
same
array
every
time
so
put
it
basically
into
the
register.
I
did
the
thing
you
see
in
the
lower
part.
B
Yes
well,
this
did
something:
I
could
go
down
with
with
the
Rost
code
to
the
same
amount
of
time.
The
C
extension
used
to
have
before,
but
see
also
improved.
A
little
bit.
I
mean
I
back
ported
that
to
see
to
be
to
have
a
fair
in
a
benchmark
here
and
also
cement
a
little
bit
down,
but
but
here
right
I
see
that
the
to
rust
and
C
they
come
come
closer
together.
A
B
Was
my
first
part?
The
second
part
is
I
want
to
go
a
little
bit
into
detail
of
the
piyo
3,
so
I,
just
in
the
first
first
part,
I
talked
a
little
bit
about
new
numerix,
and
here
I
want
to
talk
a
little
bit
about
the
interface
between
Python
and
rust,
and
what
you
can
see
here
is
very
simple
small
example,
where
I
simply
do
a
matrix
multiplication
and
I'm
using
PI
of
3
to
make
it
accessible
to
Python.
B
B
So-Called
rust
macro
in
front
of
the
function
and
then
rust
or
something
it
rewrites,
this
function,
and
it
basically
writes
for
you
all
the
boilerplate
code,
which
you
have
to
do
by
hand
and
see,
for
example,
the
above
PI
module
macro.
What
it
does.
It
creates
a
Python
module
for
you
out
of
this
function.
This
function
has
to
have
some
special
signature
that
it
works
and
the
the
inner
macro
did
pi,
f
n.
This
will
provide
some
Python
function
inside
that
module
here
called
matrix
multiplication.
B
As
you
can
see
here,
this
matrix
multiplication,
it
takes
rust
objects
and
this
decorator
this
sorry,
this
macro
will
convert
these
rust
types
into
the
corresponding
Python
types,
and
you
know
what
you
also
can
see
here
at
line
number
one
I'm
using
an
umpire
extension
of
to
pile
three.
So
this
is
available.
I
just
can
take
an
umpire
array
from
Python
and
convert
it
to
PI
array
object,
which
is
a
rust
object
and
I.
A
A
B
B
The
simple
example:
by
the
way
music
I
made
this
available
on
get
I
will
in
the
last
slide,
we
will
see
a
link
to
it
so
to
compile
what
what
after
you
do?
What
do
you
have
to
do?
To
compile
this
example?
You
just
run
cocoa,
build
as
you
would
do
it
for
for
ordinary
lost
project.
You
can
also
specify
a
release
if
you
want
optimizations
and
then
all
you
have
to
do.
Is
you
have
to
copy
or
move
the
resulting
binary,
the
library
into
the
folder?
B
You
want
to
run
the
python
code
or
to
your
Python
path,
library,
power,
and
it
you
have
to
give
it
a
certain
name.
The
name
has
to
be
exactly
the
same
as
you
name
your
function
here,
PI
of
3mm,
then
you
can
run
Python
within
with
rust,
which
is
rust,
powered.
How
would
you
do
that
in
Python?
You
just
would
import
this
PI
o
3mm,
which,
which
is
this
library.
B
A
B
The
numpy
provides
you
this
nice
add
operator
which
does
matrix
multiplication
just
by
using
this
operator
that
still
you
can
see
if
you
run,
if
you
will
run
this
code,
that
the
same
thing
pops
out
in
both
cases-
and
you
can.
What
you
also
can
see
is
that
your
last
code
will
authorize
the
correct
exception
and
if
you
try
to
multiply
matrices
with
which
which
non
matching
shapes
okay.
B
So
what
else
can
you
do
with
peyote?
You
can
define
custom
Python
types,
I'm
I
put
a
remark
here:
it's
version
Oh
God
eight.
Only
here
in
the
recent
most
recent
release,
0.9
the
syntax
would
look
a
little
bit
more
simpler,
but
for
my
project,
I
was
using
the
version
0.8,
because
this
non-prime
module
was
using
0.8
until
very
recently.
So
the
next
thing
I
will
do
miss.
My
project
is
to
build
a
greata
to
the
open
No.
So
but
anyway,
here
you
can
see
how
you
define
a
new
pattern,
type
using
just
rust.
B
You
just
declare
ordinary
rust
struct
here.
In
this
example,
it
contains
just
a
float,
and
then
you
also
give
you
apply
rust
macro
on
it,
the
PI
class
macro,
and
this
one
will
define
all
the
boilerplate
code
for
you
that
so
the
Titan
knows
what
to
do
with
this,
and
what
I
also
have
to
do
is
I
if
I
want
Python
to
be
able
to
in
Stanzi
ate
such
an
object.
I
have
to
provide
my
own
new
function,
as
you
can
see
here
with
the
new
macro
this
in
just
injects
from
from
the
Python
code.
B
This
Python
flowed
into
my
last
object
and
then
I
can
work
with
my
rust
object,
as
it
was
just
dipped.
Eclair
Daz
above
50
struct
declaration
here,
and
the
last
thing
I
have
to
do
with
this
thing
is
I
have
to
add
it
to
my
module,
and
that
is
the
third
last
row.
Third
loss
line
here,
I'm
at
cause
and
then.
B
Conversion
for
you
from
Python
objects
to
rust
objects,
and
the
other
way
also-
and
if,
for
some
reason,
some
object
does
not
support
this,
you
can
implement
the
front
PI
object.
Trade
in
this
example
I'm
implementing
this
trade
for
40,
oh
by
the
way,
this
I
think
this
this
this
wouldn't
go
here.
My
my
snippet
wouldn't
go
because
you
are
you
want
here.
B
B
Well,
so
did
this
is
basically
my
first
overview
of
piyo
3.
Now,
when
you
develop
some
code,
you
finally
also
want
to
release
it,
and
here
the
most
modern
approach
is
seems
not
to
be
the
set
of
tools.
So
there
is
some
plugins
piyo
3
setup
tools,
but
this
seems,
madam
this
disc.
This
this
tool,
muttering
matron,
seems
to
be
preferred.
Now
you
can
install
it
with
cargo
or
you
can
also
can
install
it
with
pip.
There
is
also
Python
package
providing
wrapping
basically
wrapping
this.
This
rust
object.
B
What
your
the
project
has
to
look
like.
Is
you
just
make
your
project
folder?
You
define
your
usual
telugu
tamil
in
within
the
cargo
tamil.
You
specify
the
metadata,
which
would
usually
be
in
your
setup
pi,
and
then
you
put
your
python.
If
you
have
a
mixed
project,
you
put
your
python
code
in
a
package.
B
B
A
A
B
Which
you
are
used
when
you
develop
C
extensions?
Okay,
these
two
measuring,
so
my
my
impression
from
PI
3
is:
it
is
still
in
heavy
development.
Some
things
are
confusing,
especially
for
me.
You
have
basically
tourist
types
for
object
for
the
Python
object.
It
is
PI
any
and
s
PI,
object
and
I
mean
I
still
don't
know.
B
This
sounds
very
similar
to
me
still
here.
You
have
in
the
in
one
case.
If
you
want
to
extract
something
from
from
a
ticket,
this
is
the
first
case
the
new.
You
only
need
these
three
lines
here
to
these
all
these
two
lines
within
the
function
and
when
you
want
to
get
something
out
of
a
Python
object,
and
you
have
to
acquire
this
global
interpreter
lock
of
Python,
get
the
object
out
and
convert
it.
B
I
just
had
to
write
half
the
code,
I
would
have
to
use
in
C
and
I
also
have
some
ideas
which
work
on
one
could
improve
here.
I
mean,
as
you
saw,
peyote
already
provides
some
macros,
but
it
would
be
very
cool
to
not
have
to
manually
implement
this
to
PI
object
trade
all
the
time,
so
it
would
be
cool
to
have
something
like
a
macro
data
class
or
something
which
automatically
writes.
B
Also
for
you,
a
constructor
for
for
some
type
of
for
some
rust
struct
you
defined
so
that
just
one
macro
and
you
are
done
there
are
already
such
things
available
at
github.
In
this
example
here,
which
are
which
you
see
here,
you
can
automatically
let
you
write
a
ticket
to
derive,
meaning
you,
you
write
a
struct
struct,
you
use
their
macro
and
it
will
write
to
a
converter
which
will
turn
a
properly
structured,
Python
dict
into
your
roast
struct.
So
that's
already
very
nice
and
okay.
The
other
thing,
maybe
is
crazy
idea
is
used
easy.
B
Okay,
this
is
basically
it
what
I
have
to
say
for
today,
and
here
you
have
the
links
that
the
the
first
thing
I
show
here
is
my
simple
peyote
demo
with
the
matrix
matrix
multiplication,
then
this
lights,
I,
showed
to
you
here
available
at
the
second
link
and
the
down
hold
heat.
Exchanger
simulation
is
the
last
link
thanks
very
much
I
give
back
to
Stefan.
A
A
Hello,
everybody,
so
we
have
a
short
delay
after
everything
is
synced
up
thing,
yep
I
think
we
have
cashed
up
Gary.
Can
you
hear
me
on
the
direct
line?
Yes,
wonderful,
so
what
we
did
first.
Thank
you
very
much.
So
we
are
having
a
faster
connection
between
the
two
of
us,
because
they're
on
trip
over
twitch
is
like
10
seconds.
B
A
B
A
A
B
A
A
That
leads
us
to
the
next
question,
which
is
about
linearization.
So
the
question
was:
do
you
need
to
have
an
array
to
linearize
memory
operations
on
top
of
it,
which,
if
I
remember
correctly
from
university?
If
you
have
two
matrices
and
then
rotate
one,
then
you
have
linear
access
over
both
of
them.
To
do
your
multiplication?
B
Okay,
so
the
question
I
think
step.
One
is
asking:
is
you
have
your
array
in
some
memory
view,
so
there's
a
contiguous
alignment
of
all
these
floats
and
if
you
I
mean
I
think
Stephin
is
is
telling
that
if
you
go
step
by
step,
one
element
by
one
element,
you
are
faster
than
if
you
jump
from
one
row
to
the
next
row,
because
that
means
you
have
to
jump
a
little
bit
in
the
memory
which
which
which
costs
you
time
and
the
optimization
I
did
before
was
not
about
that.
B
The
optimization
I
showed
you
before
was
just
I
went
sequentially
within
the
array
from
one
element
to
the
next,
but
in
each
iteration,
I
still
access
the
previous
one,
together
with
the
actual
world
and
I
stored,
the
previous
one
into
a
register,
so
that
I
didn't
have
to
go
one
back
again
and
just
learn
just
to
use
just
to
use
the
next
one.
And
of
course
it
is
important
to
transpose
your
matrix
matrices.
B
A
B
So
question
number
four
somebody's
isn't
asking
about
the
choice
of
Python.
We
asked
him
if
I
would
restart
this
project
from
scratch.
Would
I
still
use
Python?
The
answer
is
yes,
because
the
people
at
sustainable
system
solutions
they
are
required
to
run
Python
there.
They
also
can't
use
any
other
language
because
they
yeah.
B
B
B
So
pi
PI,
maybe
but
number
and
sidon
would
be
some
domain-specific
languages
which
would
bind
me
to
the
Python
environment,
whereas
if
I
switch
to
C
and
rust,
I
also
could
use
the
code
base
force
as
a
library
for
other
projects
which
don't
have
to
be
python-based,
I
mean,
of
course,
there
are
some
ways
to
also
bind
Python
code
into
other
languages,
but
still
I
just
wanted.
One
reason
was
I
just
wanted
to
learn
rust.
The
second
reason
I
wanted
to
be
native
and
flexible,
so
the.
B
B
Question
is
number
seven
quarantine,
beard,
no
style
beard.
B
B
A
All
the
questions
I
haven't
seen
any
other
questions
quickly.
Checking
meetup
calm
doesn't
look
like
it
wonderful.
So
if
you
and
I
would
do
a
quick
summary
of
our
experience
tonight,
it
was
very
pleasant
for
me.
I
hope
you
enjoyed
it
too.
A
A
What
do
you
have
some
feedback
for
us?
We
try
to
minimize
the
delay
as
much
as
possible.
I
hope
that
works.
Somehow.
We
also
tried
to
include
the
mouse
pointer
next
time.
Oh
yeah
and
I
think
with
that
we
will
close
Thank
You
Danny
low,
very
much
for
being
our
operator
and
streaming
centre.
Thank
you,
Erhard
for
presenting
it's
very
interesting.
A
Next
step
will
be.
We
try
to
scrape
the
video
from
twitch
and
then
upload
it
after
some
minor
edits
to
the
official
rust
YouTube
channel,
and
if
you
want
to
present
now
it's
kind
of
a
great
time
because
you
don't
have
to
travel,
so
he
can
present,
for
instance,
from
Sweden
or
from
anywhere
else,
and
we
can
make
a
meet
all
together.
A
A
However,
we
don't
know
yet
so
we're
currently
looking
into
options
if
we
can
make
remote
talks
like
this
or
if
you
find
a
better
solution,
we're
testing
software
right
now,
we'll
keep
you
updated
on
that,
but
we'll
try
to
make
an
event
happening
this
year.
If
we
cannot
do
it
in
person,
we
might
do
a
half
and
half
like
half
remote,
half
impersonal
conference
or
a
full
remote
conference.
We
don't
know
yet,
but
we'll
we'll
see
how
that
goes.