Skip to content

Latest commit

 

History

History
271 lines (157 loc) · 4.54 KB

slides.md

File metadata and controls

271 lines (157 loc) · 4.54 KB

My Python's a Little Rusty

Dan Callahan · [email protected] · @callahad


The Big Lie


"Python's fast enough, and
I can always write a C extension."


But it's not, and we never do.


Why don't we write C?

1. Other people did it for us.


Lines of C/C++ in Projects

Project # Lines %
CPython 3.5.0a2 399,387 43%
NumPy 1.9.2 166,034 62%
Pillow 2.7.0 22,669 52%
MarkupSafe 0.23 178 21%

We're standing on their shoulders

And so are they.

Pillow links to libjpeg


2. Writing C is scary.


Memory management is hard.

Much like the video at

youtube.com/watch?v=718fskG2n34

C has no safety belts.


  • Heartbleed
  • Ghost
  • CVE-2015-0080

I'm not smarter than the glibc or openssl devs.


But what if you need to?


The Dream


C's Performance, Portability, and Embeddability.

With *guaranteed* safety.

Rust.


Stack vs. Heap


Stack Heap
Fast but tiny Slow but huge
Function locals Globals
Managed by CPU Unmanaged

Only small values of known, fixed size can go on the stack.
Growable things like vectors must go on the heap.


Managed vs unmanaged


 


 


 


 


Ownership


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


 


Enforced Statically at Compile Time


  • No dangling pointers
  • No use after free vulnerabilities
  • No pointer arithmetic
  • No null pointer dereferencing

This is a "Zero-Cost Abstraction."


Mutability Demos!




Python FFI Demos!


Learn More

rust-lang.org


Questions?


@callahad

[email protected]

github.com/callahad/pycon2015-rust


rust-lang.org