r/Python • • May 14 '21

Discussion Python programming: We want to make the language twice as fast, says its creator

https://www.tectalk.co/python-programming-we-want-to-make-the-language-twice-as-fast-says-its-creator/
1.2k Upvotes

229 comments sorted by

View all comments

306

u/Satoshiman256 May 14 '21

Just do less print statements/s

174

u/sizable_data May 14 '21

How else are you supposed to debug it?

74

u/Satoshiman256 May 14 '21

Haha ye. Someone posted a new logging module here a while back and I was like.... but print?

104

u/Napan0s May 14 '21

Logging? What about hundreds of 'I am here' prints

35

u/abrazilianinreddit May 14 '21

12

u/[deleted] May 14 '21 edited May 14 '21

Lol mine is more like "we made it to <function>"

→ More replies (2)
→ More replies (4)

17

u/bin-c May 14 '21

way too verbose imo

i go with:

here1

here2

here3

here4

12

u/Killed_Mufasa May 14 '21

ah yes and don't forget the "WTF HOW DID IT GOT HERE" one

7

u/bin-c May 15 '21

then you global search "WTF HOW DID IT GOT HERE" and it pops up like 10 times

3

u/Napan0s May 15 '21

This actually made me laugh

7

u/u7aa6cc60 May 14 '21

You're all exposing my deepest secrets. I feel violated. Stop.

3

u/[deleted] May 15 '21

Sometimes I do "why not zoidberg?"

→ More replies (1)
→ More replies (1)

8

u/ImperatorPC May 14 '21

Lol inside loop, outside loop, true, false omg

3

u/vikinghamster May 15 '21

print("I'm personally insulted here")

→ More replies (2)

12

u/ThatPostingPoster May 14 '21

Loggers are dope. You have to remove print statements, you don't remove smart logging statements. When you remove the print, you end up reading it sometimes. It let's you set up, always log aka print, warning log, and error log. And depending on how you run the file the logger prints those ones.

5

u/Satoshiman256 May 14 '21

Ye I need to use them. Can you suggest one?

29

u/[deleted] May 14 '21

Just use the built in logging module. It’s really the best there is. And you can pass the logging information to log files rather than to the console.

To give an example of how useful it is: a project I’m doing has me working with this horrible API. I pass the responses to a log file so I can see what I’m working with at any stage. I also have a logger/log file that checks the server connection and looks out for any exceptions triggered in the code. This is a big project, and I started with print statements but realised they slow me down significantly

→ More replies (10)

8

u/ThatPostingPoster May 14 '21 edited Nov 02 '21

gg ez deleted cause reasons lets go ok gg is this enough characters to not flag auto mod i hope so lmao

3

u/whateverathrowaway00 May 14 '21

Yup.

And the python built in logger is fantastic. It’s a straight port of log4j and is ridiculously easy to use well once you play with it once or twice.

Pretty much everything I make is filled with log statements and since I always use the module of packaged library with a CLI entry point that runs it, the CLI entry point just attaches the logger to the stdout, enables debug if it sees the flag and boom.

Everything always usable as module in silent mode or verbose with the right entry point.

→ More replies (3)
→ More replies (7)

3

u/Windows_XP2 May 14 '21
print("It works!")

5

u/Jmortswimmer6 May 14 '21

Vscode has a nice integrated debugger....honestly, you’re just shooting yourself in the foot if not using vscode/pylance/venv

13

u/sizable_data May 14 '21

My preference is pycharm, big debate on my team with VS code users though. A lot of my work is also in Jupyter lab which also supports debugging with the 3.0 release. You need a custom kernel though (xeus Python)

8

u/Jmortswimmer6 May 14 '21

A lot of people love pycharm. I tried it in college....It is just far too nice to have vscode’s C/C++/.sh/etc. support right next to my python, often i have these languages also incorporated into any project. The integrated terminal is a nice feature, and the editor has many other general editing features that make writing python much nicer.

→ More replies (1)
→ More replies (9)

6

u/[deleted] May 14 '21 edited May 14 '21

You laugh but one of the first thing I do when I start a new project is write a dprint() so that I can customize it to my project. I prefer the logger module when things start getting serious but sometimes if I'm just playing around I don't need the added complexity until I really get going.

→ More replies (6)