SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
Why Python, Ruby, and
 Javascript are slow
       Alex Gaynor
       Waza 2013
You may know me
     from...
rdio.com
• CPython
• Django
• PyPy
Twitter rants about
how computers are bad
Topaz
topazruby.com
There is no benchmark
 but your benchmark
Lame Excuses about
 why they’re Slow
Dynamic Typing
“You can monkey patch
       anything”
Harder to Optimize
        vs.
       Slow
The Truth
Let’s talk about C
struct Point {
    double x;
    double y;
    double z;
};
class Point(object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z
data = {
    "x" x,
    "y": y,
    "z": z,
}
Dictionary
    vs.
 Object
std::hash_set<std::string, double> point;
point["x"] = x;
point["y"] = y;
point["z"] = z;
And it would be slow
Why don’t people care?
Let’s talk about strings
Given a string
  matching: “w+-d+”
return the integral part
      of the value
int(s.split("-", 1)[1])
atoi(strchr(s, '-') + 1)
Things that take time

• Hash table lookups
• Allocations
• Copying
The C way:

  BYOB
char *data = malloc(1024);
while (true) {
    read(fd, data, 1024);
    char *start = data;
    while (start < data + 1024) {
        if (isspace(*start)) {
            break;
        }
        start++;
    }
    printf("%sn", start);
}
while True:
    data = os.read(fd, 1024)
    print data.lstrip()
long *squares(long n) {
    long *sq = malloc(sizeof(long) * n);
    for (long i = 0; i < n; i++) {
        sq[i] = i * i;
    }
    return sq;
}
def squares(n):
    sq = []
    for i in xrange(n):
        sq.append(i * i)
    return sq
Missing APIs
from __pypy__ import newlist_hint
def squares(n):
    sq = newlist_hint(n)
    for i in xrange(n):
        sq.append(i * i)
    return sq
Don’t make us add
   heuristics
Heuristics = WAG
Growing divide
between optimizing and
         not
Recap

• Line for line these languages are fast!
• Take care in data structures (data structure
  heuristics are the WORST)
• We need better no-copy/preallocate APIs
Don’t abandon beauty,
simplicity, our values for
      performance

  Make performance
      beautiful.
Thank you!
https://speakerdeck.com/alex
        @alex_gaynor
If there’s time

• Java collections vs. Array and Hash. Need
  more choices.
• Stop writing C extensions, use something
  like cffi
• Teach good benchmarking practices

Mais conteúdo relacionado

Mais procurados

CrystalBall - Compute Relative Frequency in Hadoop
CrystalBall - Compute Relative Frequency in Hadoop CrystalBall - Compute Relative Frequency in Hadoop
CrystalBall - Compute Relative Frequency in Hadoop Suvash Shah
 
2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my
2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my
2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh myRyan M Harrison
 
ggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphicsggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality GraphicsClaus Wilke
 
In The Land Of Graphs...
In The Land Of Graphs...In The Land Of Graphs...
In The Land Of Graphs...Fernand Galiana
 
The Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: VisualizationThe Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: VisualizationMongoDB
 
The Weather of the Century
The Weather of the CenturyThe Weather of the Century
The Weather of the CenturyMongoDB
 
Assignment of pseudo code
Assignment of pseudo codeAssignment of pseudo code
Assignment of pseudo codeBurhan Chaudhry
 
Weather of the Century: Visualization
Weather of the Century: VisualizationWeather of the Century: Visualization
Weather of the Century: VisualizationMongoDB
 
Edu presentation1
 Edu presentation1 Edu presentation1
Edu presentation1hook1kf
 
openCypher: Technology Compatibility Kit (TCK) and Vendor Extensions
openCypher: Technology Compatibility Kit (TCK) and Vendor ExtensionsopenCypher: Technology Compatibility Kit (TCK) and Vendor Extensions
openCypher: Technology Compatibility Kit (TCK) and Vendor ExtensionsopenCypher
 
From Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and ScaleFrom Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and ScaleBadrish Chandramouli
 
Statistics - ArgMax Equation
Statistics - ArgMax EquationStatistics - ArgMax Equation
Statistics - ArgMax EquationAndrew Ferlitsch
 
Mpmc unit-string manipulation
Mpmc unit-string manipulationMpmc unit-string manipulation
Mpmc unit-string manipulationxyxz
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPaulo Sergio Lemes Queiroz
 
Writing mdb to excel
Writing mdb to excelWriting mdb to excel
Writing mdb to excelyogeshdxt8
 
Cloud flare jgc bigo meetup rolling hashes
Cloud flare jgc   bigo meetup rolling hashesCloud flare jgc   bigo meetup rolling hashes
Cloud flare jgc bigo meetup rolling hashesCloudflare
 
CSS: The Boring Bits
CSS: The Boring BitsCSS: The Boring Bits
CSS: The Boring BitsPeter Gasston
 

Mais procurados (20)

CrystalBall - Compute Relative Frequency in Hadoop
CrystalBall - Compute Relative Frequency in Hadoop CrystalBall - Compute Relative Frequency in Hadoop
CrystalBall - Compute Relative Frequency in Hadoop
 
2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my
2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my
2019-01-24 Sequelize ORM (Object Relational Mapper): models, migrations, oh my
 
ggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphicsggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphics
 
In The Land Of Graphs...
In The Land Of Graphs...In The Land Of Graphs...
In The Land Of Graphs...
 
R
RR
R
 
The Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: VisualizationThe Weather of the Century Part 3: Visualization
The Weather of the Century Part 3: Visualization
 
Mate tarea - 2º
Mate   tarea - 2ºMate   tarea - 2º
Mate tarea - 2º
 
The Weather of the Century
The Weather of the CenturyThe Weather of the Century
The Weather of the Century
 
Assignment of pseudo code
Assignment of pseudo codeAssignment of pseudo code
Assignment of pseudo code
 
Weather of the Century: Visualization
Weather of the Century: VisualizationWeather of the Century: Visualization
Weather of the Century: Visualization
 
Kwp2 091217
Kwp2 091217Kwp2 091217
Kwp2 091217
 
Edu presentation1
 Edu presentation1 Edu presentation1
Edu presentation1
 
openCypher: Technology Compatibility Kit (TCK) and Vendor Extensions
openCypher: Technology Compatibility Kit (TCK) and Vendor ExtensionsopenCypher: Technology Compatibility Kit (TCK) and Vendor Extensions
openCypher: Technology Compatibility Kit (TCK) and Vendor Extensions
 
From Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and ScaleFrom Trill to Quill: Pushing the Envelope of Functionality and Scale
From Trill to Quill: Pushing the Envelope of Functionality and Scale
 
Statistics - ArgMax Equation
Statistics - ArgMax EquationStatistics - ArgMax Equation
Statistics - ArgMax Equation
 
Mpmc unit-string manipulation
Mpmc unit-string manipulationMpmc unit-string manipulation
Mpmc unit-string manipulation
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Writing mdb to excel
Writing mdb to excelWriting mdb to excel
Writing mdb to excel
 
Cloud flare jgc bigo meetup rolling hashes
Cloud flare jgc   bigo meetup rolling hashesCloud flare jgc   bigo meetup rolling hashes
Cloud flare jgc bigo meetup rolling hashes
 
CSS: The Boring Bits
CSS: The Boring BitsCSS: The Boring Bits
CSS: The Boring Bits
 

Destaque

Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David GouldinHeroku
 
Librato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor Apps
Librato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor AppsLibrato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor Apps
Librato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor AppsHeroku
 
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of IndifferenceRob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of IndifferenceHeroku
 
Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013Heroku
 
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's BusinessCodeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's BusinessHeroku
 
Heroku webcastdeck+20130828
Heroku webcastdeck+20130828Heroku webcastdeck+20130828
Heroku webcastdeck+20130828Heroku
 
Heroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer ApplicationsHeroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer ApplicationsHeroku
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and HerokuTapio Rautonen
 

Destaque (8)

Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David Gouldin
 
Librato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor Apps
Librato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor AppsLibrato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor Apps
Librato's Joseph Ruscio at Heroku's 2013: Instrumenting 12-Factor Apps
 
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of IndifferenceRob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference
 
Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013
 
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's BusinessCodeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
 
Heroku webcastdeck+20130828
Heroku webcastdeck+20130828Heroku webcastdeck+20130828
Heroku webcastdeck+20130828
 
Heroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer ApplicationsHeroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer Applications
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and Heroku
 

Semelhante a Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are Slow

Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
Ayudando a los Viajeros usando 500 millones de Reseñas Hoteleras al Mes
Ayudando a los Viajeros usando 500 millones de Reseñas Hoteleras al MesAyudando a los Viajeros usando 500 millones de Reseñas Hoteleras al Mes
Ayudando a los Viajeros usando 500 millones de Reseñas Hoteleras al MesBig Data Colombia
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7decoupled
 
When RegEx is not enough
When RegEx is not enoughWhen RegEx is not enough
When RegEx is not enoughNati Cohen
 
json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college projectAmitSharma397241
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
 
Basics of Javascript
Basics of JavascriptBasics of Javascript
Basics of JavascriptUniverse41
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to pythonActiveState
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional ProgrammingYuan Wang
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
Data science at the command line
Data science at the command lineData science at the command line
Data science at the command lineSharat Chikkerur
 
Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)Qiangning Hong
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developersJim Roepcke
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software DevelopmentNaveenkumar Muguda
 

Semelhante a Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are Slow (20)

Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
Ayudando a los Viajeros usando 500 millones de Reseñas Hoteleras al Mes
Ayudando a los Viajeros usando 500 millones de Reseñas Hoteleras al MesAyudando a los Viajeros usando 500 millones de Reseñas Hoteleras al Mes
Ayudando a los Viajeros usando 500 millones de Reseñas Hoteleras al Mes
 
What the C?
What the C?What the C?
What the C?
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
When RegEx is not enough
When RegEx is not enoughWhen RegEx is not enough
When RegEx is not enough
 
json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college project
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018Metarhia KievJS 22-Feb-2018
Metarhia KievJS 22-Feb-2018
 
Json the-x-in-ajax1588
Json the-x-in-ajax1588Json the-x-in-ajax1588
Json the-x-in-ajax1588
 
Basics of Javascript
Basics of JavascriptBasics of Javascript
Basics of Javascript
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
Data science at the command line
Data science at the command lineData science at the command line
Data science at the command line
 
Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
Python classes in mumbai
Python classes in mumbaiPython classes in mumbai
Python classes in mumbai
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 

Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are Slow