Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

WTF is up with python?

Name: Anonymous 2007-04-22 19:03 ID:QUkGtLGA

x = 0
while x < 100000000:
  x += 1

the above code takes ~35 seconds to run on my computer. WTF???

Name: Anonymous 2007-04-22 19:11 ID:8+D4DJOT

optimize it to x = 100000000
problem solved

Name: Anonymous 2007-04-22 19:14 ID:Heaven

>>2
PREMATURE OPTIMIZATION~

Name: Anonymous 2007-04-22 20:54 ID:DLp1EDt/

NO EXCEPTIONS

Name: Anonymous 2007-04-22 22:00 ID:DLp1EDt/

>>9
5. Any forced meme in /prog/ will be unfunny. No exceptions.

Name: Anonymous 2007-04-23 5:53 ID:yTJMec0x

turing, you jackass

Name: Anonymous 2007-04-23 7:54 ID:qp7LdHPo

Name: Anonymous 2007-04-23 9:53 ID:p4r9kBZv

>>7
WRITE SOME FUCKING CONTENT ON THAT PAGE PLZ

Name: Anonymous 2007-04-23 10:03 ID:H+lzKeb1

>>5

Hello :)

Name: Anonymous 2007-04-23 12:54 ID:TlQhVRak

>>1
upgrade your ram

Name: Anonymous 2007-04-23 14:01 ID:p4r9kBZv

>>10
post some actual content or GTFO you fucking faggot

Name: Anonymous 2007-04-23 14:09 ID:P/1mOR0h

>>11
I'm 16 Years of Age.
I live in Stockport, UK.
I'm currently on vacation from education which means I have more time for Wikipedia (woo!).
My favorite Wikipedia topic of choice is Doctor Who.
My Userboxes

Name: Anonymous 2007-04-23 16:37 ID:9sdFcF6Y

>>12
You just posted the content from my last wikipedia account userpage (it got banned). Also, stop internetstalking me you fag. Seriously. What in the name of JESUS FUCKING CHRIST.

Name: Anonymous 2007-04-23 18:23 ID:LY+YY19j

>>13

Shut up

Name: Anonymous 2007-04-23 18:33 ID:pGX5eyL8

>>1
Python on Win32: 26.828s
GCC/MinGW 3.4.2: 0.328s
(and not because of any overhead - verified with 10 iterations)

Python with psyco (dynamic specializator) on Win32: 0.047s

Hint: OWNED! FUCKING OWNED YOU FAGGOT!

Using psyco:


import psyco
psyco.full()
def main():
 #Your code begins here, intact
 x = 0
 while x < 100000000:
   x += 1


Does psyco really run 100M iterations? I doubt it. It shouldn't be faster than C. It most surely detected what I was doing was bullshit and dynamically optimized function main to return None.

Name: Anonymous 2007-04-23 21:38 ID:wXZerHH1

>>15
Finally, someone with something significant to say. The rest of you are fags. Thanks >>15

Name: Anonymous 2007-04-24 2:26 ID:f6XAXaoY

I'm not all that impressed by Psyco. I've tried in on a real-world app, and once I managed to keep it from crashing, the improvement was a meager 15%.

I had been hoping for ~200%. Ouch.

To be fair, there are a number of things in Python that aren't easy to optimize, but Psyco is excellent evidence that microbenchmarks are close to worthless. :(

Name: Anonymous 2007-04-24 2:32 ID:5WlKgw3k

>>13
hahahah, you got owned by your step brother

Name: Anonymous 2007-04-24 2:52 ID:BJViy29q

>>15
module Main where

main = do
   let a = sum [1..100000000]
   return ()


$ time ./bs
real    0m0.002s
user    0m0.000s
sys     0m0.000s

OWNED OWNED OWNED

Name: Anonymous 2007-04-24 3:27 ID:Eyr50gcR

>>13
Underage GTFO ;)

Name: Anonymous 2007-04-24 5:54 ID:VB3xRVz+

>>19
Lazy evaluation aside, that doesn't even do the same thing.

Name: Anonymous 2007-04-24 5:56 ID:kMB0lN3Y

x=99999999

Name: Anonymous 2007-04-24 6:56 ID:BJViy29q

>>21
Yes it does, but in any case, this is an exact translation:
module Main where

import Control.Monad (forM_)
import Control.Monad.ST
import Data.STRef

main = do
    let a = runST (do x <- newSTRef 0
                      forM_ [1..100000000] (\_ ->
                          modifySTRef x (+1))
                      readSTRef x)
    return ()

Name: Anonymous 2007-04-24 7:00 ID:BJViy29q

>>21
Oh right, doh. It doesn't.

Name: Anonymous 2007-04-24 7:01 ID:Heaven

>>19
sum [1..100000000] /= 100000000

Name: Anonymous 2007-04-24 7:04 ID:u84xehVB

>>17
Naturally, it won't improve C extensions (which are supposed to be fast), and it won't improve I/O operations themselves (which are the same from any language). IIRC, it won't improve some features such as lambads either. But it will improve most of your Python code. If you saw a 15% performance increase instead of a 200%, then perhaps the same application written in C wouldn't be so much faster either. It's the kind of thing you're doing what cannot be optimized as much. Microbenchmarks or not, other applications such as those that rely on a lot of Python code for Maths will get a massive performance increase.

And 15% is not bad at all, considering you get free extra performance without (virtually) any modifications to your source code and working in a highly dynamic language which is well over a dozen times more productive than C or C++. Quit complaining.

Name: Anonymous 2007-04-24 7:36 ID:BJViy29q

>>25
Thanks. It's hard to decipher imperative code.

Name: Anonymous 2007-04-24 12:01 ID:f6XAXaoY

>>26
If you saw a 15% performance increase instead of a 200%, then perhaps the same application written in C wouldn't be so much faster either.
Given the workload mix (plenty of CPU) and the size of the app, I quite doubt that.

And 15% is not bad at all [etc]
While I agree with the sentiment of your last paragraph, I should point out that this app ran the business. In other words, app crashes, money lost, heads roll. 15% is risible in that situation.

I probably wouldn't have used Psyco on the servers even if it gave a 200% boost (in the end we went out and bought another rack). I can't see anyone using Psyco for anything serious because of the confidence issues.

Name: Anonymous 2007-04-24 12:05 ID:u84xehVB

>>27
Lol

Name: Anonymous 2007-04-24 12:46 ID:P1Xc6tKM

>>1
ONE WORD,
 THE FORCED IDENTATION OF CODE
  THREAD OVER!

Name: Anonymous 2007-04-24 14:46 ID:IdXweCSv

DO A ROLLING LOOP FOR SPEED

int x = 0
while (x < 100000000)
{
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
  ++x;
 ...

Name: Anonymous 2007-04-24 14:57 ID:Eyr50gcR

DRRRRRRRRRRRRRR

Name: Anonymous 2007-04-24 14:59 ID:P1Xc6tKM

>>31
-fbarrel-roll-loops

Name: WRYYYYYYY 2007-04-24 15:01 ID:Heaven

SHITE SUX LOLS

Name: Anonymous 2007-04-24 15:02 ID:Eyr50gcR

sage

Name: Anonymous 2007-04-24 15:02 ID:Eyr50gcR

sage

Name: Anonymous 2007-04-24 15:10 ID:IdXweCSv

n-gage

Name: Anonymous 2009-01-14 12:39

LISP

Name: Anonymous 2009-03-06 7:20

The next iteration of.

Name: Anonymous 2011-02-03 7:50


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List