Python

python general
bonus:
whats our official opinion of python

Other urls found in this thread:

github.com/BurntSushi/xsv
benchmarksgame.alioth.debian.org/u64q/python.html
flask.pocoo.org/docs/0.10/api/
docs.python.org/3/tutorial/modules.html#packages
lwn.net/Articles/724454/#723823
twitter.com/AnonBabble

Same as it is with everything of course: it's shit.

...

Python 2 is better than 3. They fucked up making a split but since the split almost everyone still codes with 2. Pythin is a really good language because you can "get shit done", which is why its called a prototyping language. The run-time performance is poor, but for 99% of text-based programming you never notice the difference.

Not sure man. In my experience, It does anything related to file I/O pretty fast. Once had to generate a 40 mil line csv with random data to stress test a server. Did it in bash- took minutes, then rewrote it in python and it literally took about 10 seconds to finish.

what's going on with that split? django dropped support for python2 in there future updates. django is the biggest python thing i know of as far as people depending on it to get shit done. I imagine there will be drama

IT'S FUCKING BOTNET

...

How did you make the bash one? If you did it a certain way you may have opened and closed the file sequentially 40 million times. That's slow no matter what.

kek. use xsv next time.
github.com/BurntSushi/xsv

it's a much better language to teach total noobs with than basic?
it's fine, really. these kinds of questions are always like
depends on what i fucking need to accomplish today, doesn't it

Stop resisting the collective. You'll be happier once you're part of the whole.

What makes Python 2 better for prototyping than Python 3?

nice poz

I resisted Python for a long time, because I fell for pre-optimization even down to the choice of language. I cooled my autism, and now Python is one of my favorite languages. I often need to make quick and dirty scripts or prototypes. I get paid to teach programming, and Python is just so close to English if written clearly. I'm writing a RESTful web API in Django now when I would have made it directly extending Java HttpServlets.

Considering how simple the syntax is and how 'just werks' it is, Python is surprisingly fast. It's never going to be as fast as something like C, but it's still lightning fast compared to Java, something designed to be a better C++. I know Java isn't a high bar to set but still.

Take the following simple while loops in both Python and Java:

speedtest.py
x = 1while x < 100: print(str(x)) x += 1

speedtest.java
public class speedtest { public static void main(String[] args) { int x = 1; while (x < 100) { System.out.println(x); x += 1; } }}

Running time python3 speedtest.py in GNU/Linux produces the following times (on average):
real 0m0.019suser 0m0.016ssys 0m0.004s

On the other hand running time java speedtest in GNU/Linux, after compiling it of course, produces the following times (on average):
real 0m0.103suser 0m0.160ssys 0m0.020s

It's easy to see that Java is a steaming pile of shit, even compared Python which is so often called a slow language.

TL;DR Java is shit, Python's pretty gud.

Since python3.6 there has been a significant improvement in performance. Dictionaries are key-sharing and ordered

nothing

How does it compare to using range and not casting to str?

prototype real fast,
bad for proper program

i think that's the general idea

this is horse shit

your test is retarded because it measures interpreter startup time, the actual code does pretty much zero CPU-bound work, and using terminal-backed stdout also introduces noise into time measurements. you obviously don't know a jack shit about proper benchmarking.

youtube-dl is written in Python and it's entirely okay.
maybe you just don't know how to python.

Python is good when:

youtube-dl is slow. I use it on my Android phone to download videos, and just doing `youtube-dl --help` takes like 15 seconds. mps-youtube is even worse.

Python is still okay when performance does matter but you can keep the bottleneck inside a compiled library. See numpy, for example.

In his defense, he unironically used GNU/Linux.

I just tested it here and it does take an insane amount of time before it shows anything. I doubt that's a typical python thing though, it must be something withing youtube-dl.

n.v.m. in a second run it's quick, so it probably had to load a bunch of python libs the first time.

python is good
easy to learn and reads very easily

zed pls go

what's the disadvantage of using pypy?
surely there has to be something wrong with it? why would anyone use c++ if python could be made to run so fast?

not all libraries work with pypy becase it's C api isn't 100% compatible yet. Scikit-stuff, scipy, pandas, and matplotlib A big chunk of python users need those. Hell, even webdevs can't quite use it yet because it doesn't support PostgreSQL (psycopg2)

It's a simple scripting language.
My observation tends to say that the community went to big suddenly and the existing libraries are a total mess.
It's good to learn some elementary logic not for big and extensive programing.


It teaches the elementary but not the basics.
Scheme (and the little schemer) is better for that.

Any non-trivial program will be much faster in Java, specially if you take some minimal precautions to avoid stressing the GC (something Minecraft, the only Java program you kiddies know, doesn't don even though it would be trivial). Educate yourself, nigger.

benchmarksgame.alioth.debian.org/u64q/python.html

I use it when I need to make something fast, bash doesn't have the programs for it, and performance doesn't matter. Everything else is just c.

This is a dumb question tbh but I'm finding myself stuck on an explanation from the flask api:

>So it’s important what you provide there. If you are using a single module, name is always the correct value. If you however are using a package, it’s usually recommended to hardcode the name of your package there.
>app = Flask(name.split('.')[0])
>Why is that? The application will work even with name, thanks to how resources are looked up. However it will make debugging more painful. Certain extensions can make assumptions based on the import name of your application. For example the Flask-SQLAlchemy extension will look for the code in your application that triggered an SQL query in debug mode. If the import name is not properly set up, that debugging information is lost. (For example it would only pick up SQL queries in yourapplication.app and not yourapplication.views.frontend)

from: flask.pocoo.org/docs/0.10/api/

What would it mean to be using a package rather than a single module?
Would that be if I was instanciating the app in a package, and then importing that package into a python module that'd make use of it?

Also, what's the purpose of passing in name.split('.')[0] rather than name? Unless I'm misunderstanding, that example is provided for the case of instanciating the app inside a single module, and shouldn't name.split('.')[0] be equal to name in all cases?

What is happening in that picture?

Looks like they're attacking the speed camera system via its OCR. Camera takes photo of car, gets license plate text (in this case, with all the database shit), passes text unsanitised through to database.

thanks user

upvoting question

docs.python.org/3/tutorial/modules.html#packages
That example is for yourapplication/app.py, which is a module inside a package, not a module on its own. _ _name_ _ then becomes "yourapplication.app" or something like that.

another cancerous Pythong API

from random import sampledef card_gen(ball,grid): assert ball % grid == 0 and ball > grid ** 2 and grid % 2 == 1 row = ball // grid return [sorted(sample(range(i*row+1,(i+1)*row+1),grid)) for i in range(grid)]class bingo(object): def __init__(self, ball, grid): self.ball = ball self.grid = grid self.row = ball // grid self.card = card_gen(ball, grid) self.status = [[False]*grid]*grid self.win = False def call(self, num): assert self.ball >= num self.status = [[self.status[i][j] or (self.card[i][j] == num) for j in range(self.grid)] for i in range(self.grid)] return self def check(self): for i in self.status: self.win |= (i == [True]*self.grid) for i in range(self.grid): self.win |= ([row[i] for row in self.status] == [True]*self.grid) if [self.status[i][range(self.grid)-i-1] for i in range(self.grid)] == [True]*self.grid \ or [self.status[i][i] for i in range(self.grid)] == [True]*self.grid: self.win = True return self

lol user he really is right.

ruby looks cute

your own unreasonable behavior doesn't prove anything.

web frameworks are overhyped.
actually you only need a web server implementation, and everything on top of that is easy to do anyway.

everywhere i go on the internet there's these stupid Holla Forums tier faggots saying
and reddit/typical leftist nerd faggots saying

What do the pythomissiles think about this?

lwn.net/Articles/724454/#723823 (scroll down to 'Python as a security vulnerability')

python -c "exec(urlopen(...).read())"

wow thats cool and totally unique to python and not any other scripting language.

Seems like a problem with most languages in Python's niche, including Perl and Ruby. It's something I would love to see improved, but it's not at all unique to Python - it's just that this person is urging Python in particular to improve.
But I'd have to watch the talk to be sure.

RestrictedPython solves part of that problem I think.