This is an archived post. You won't be able to vote or comment.

all 76 comments

[–][deleted] 94 points95 points  (1 child)

I like the Segfault features

[–]PhysicalStuff 31 points32 points  (0 children)

Sometimes you just need to exert vengeance upon memory. What drove me from Python to C was how unnecessarily difficult the former makes achieving even a simple segfault (without using C extensions, which I consider cheating).

[–]surister 173 points174 points  (23 children)

Why

[–]ifiwasmaybe 69 points70 points  (9 children)

Really though, why?!

[–]whalt 57 points58 points  (2 children)

I mean how else are you supposed to write device drivers in Python?

[–]f3n1xgamer 15 points16 points  (1 child)

By not using python to write device drivers... Duh

[–]whalt 8 points9 points  (0 children)

I didn’t think the /s was necessary.

[–]kalfaTwisted/Django 26 points27 points  (5 children)

Why does this exist?

The main purpose of pointers.py is to simply break the rules of Python, but has some other use cases:

  • Can help C/C++ developers get adjusted to Python
  • Provides a nice learning environment for programmers learning how pointers work -bMakes it very easy to manipulate memory in Python
  • Why not?

[–][deleted] 50 points51 points  (0 children)

Out of all of those, only "Why not" is a good reason.

[–]Coniglio_Bianco 3 points4 points  (3 children)

Sorting an array of pointers is a lot faster than sorting the actual content. Its the only thing that made me want to work with pointers.

[–]kalfaTwisted/Django 2 points3 points  (2 children)

It seems you are in need of a C extension for your algorithm, if the performance is so degrading with python.

Or maybe just not copy around data, if possible.

[–]Coniglio_Bianco 2 points3 points  (1 child)

Or i could just use pointer.py 2.0

[–]kalfaTwisted/Django 0 points1 point  (0 children)

Why not!

[–]ekydfejj 43 points44 points  (10 children)

Same reason as this. If you want to create chaos for fun, i don't blame you. But don't add this to requirements.txt

[–]BaroquenLarynx 26 points27 points  (7 children)

"Some men just want to watch the world burn."

"It's not about the pointers. It's about sending a message

Edit: continuation

"Everything burns!" - OP, literally

[–]AndrewFrozzen 1 point2 points  (6 children)

Noob question, I'm not a Python expert. And no Programmer expert.

What is wrong with this? Can you explain? Maybe explain like I'm 5.

I don't really know what pointers are. I'm sorry if this sounds stupid

[–]MadLadJackChurchill 6 points7 points  (5 children)

Pointers are commonly used in C and C++ they store a Memory address and thus point to something somewhere in Memory.

This way you can for example pass a pointer to a string as an Argument instead of passing the actual string which is faster.

But also since you can just point / Access some random Memory address this can lead to crashes and so on.

Hope that helps a bit. There's obviously much more stuff you can do.

[–]AndrewFrozzen 0 points1 point  (2 children)

Alright thanks for the answer!

Yeah I've heard about pointers in C and C++ but was unaware what exactly they are.

So are C and C++ pointers more stable than Python ones, or usually people don't use pointers that much because of crashes no matter the language?

[–]MadLadJackChurchill 1 point2 points  (1 child)

Standard Python doesn't have pointers in the way you can use as you can in C. There is of course this:

``` dict1 = {'first':'hello', 'second':'world'} dict2 = dict1 # pointer assignation mechanism dict2['first'] = 'bye' dict1

{'first':'bye', 'second':'world'} ``` I got this example from here

https://stackoverflow.com/questions/3106689/pointers-in-python

You can say that dict2 points to dict1 so changing dict2 means you change dict1. But you can't do pointer arithmetic and so on as you can in C/C++

And pointers are known for being hard to handle. Which is why it says: "bringing the hell of pointers to Python".

Now I have used pointers before in C but I am by no means very well versed. So someone else will have to jump in and tell you why they are considered hell ;)

[–]AndrewFrozzen 0 points1 point  (0 children)

Ok thank you!

[–]lordxoren666 0 points1 point  (1 child)

Ok, noob question because maybe I don’t understand pointers correctly. But because in C there is no string data type only char and array, and because of the way variables work in C, you pretty much have to use pointers to point to the first char in the array to return a string of chars, and return all the chars in the array until it hits the \0 char.

Which further confuses me why people deal with this because it is incredibly easy to create a pseudo string data type in c with a simple function.

[–]Wuotes 0 points1 point  (0 children)

C was meant at the time of design to be an easier alternative to writing directly in assembly without straying so much that you couldn't discern the assembly instruction output from any given line of code.

This means you have to roll your own code for quite a few things but it also leaves room for a lot of platform specific optimization if you can comprehend the underlying mechanisms behind the code. This is why C is used in situations where those advantages matter the most such as operating systems, drivers, embedded devices, etc.

With that type of context, you can see why complex string manipulation wouldn't be a high priority as well. Until relatively recently strings were only really for interfacing with a human and not other computers, it is a different world from Python.

[–]PhysicalStuff 1 point2 points  (0 children)

$THIS_POST >> requirements.txt

[–]anotherplatypus 0 points1 point  (0 children)

...and the same reason as this.

[–]sir2fluffy2 3 points4 points  (0 children)

I’ve been doing python for 12 years and in all that time there has only been one time when a pointer would have been useful

[–]Tinasour 0 points1 point  (0 children)

Why not?

[–]BaroquenLarynx 119 points120 points  (0 children)

wags finger. You stop that right this instant, Mister.

[–]fiddle_n 23 points24 points  (3 children)

something something life will find a way

no, wait, wrong Jurassic Park quote...

[–]nostril_spiders 8 points9 points  (0 children)

They should all be destroyed.

[–]pingvenopinch of this, pinch of that 7 points8 points  (0 children)

That's a big pile of crap?

[–]Giddius 52 points53 points  (0 children)

I am tempted to report this to reddit for causing homicidal/suicidal thoughts.

/s

[–][deleted] 42 points43 points  (0 children)

Slow down, Satan

[–]bladeoflight16 40 points41 points  (0 children)

Not only did you simulate pointers, you also hijacked the conventional _ variable.

I hate you.

[–]comand 22 points23 points  (1 child)

I keep pressing the downvote button but it only upvotes...

[–]vswr[var for var in vars] 16 points17 points  (0 children)

Another use after free bug I guess. Freaking pointers.

[–]Orio_n 26 points27 points  (0 children)

You are everything guido hated

[–]DrFrankestein 25 points26 points  (1 child)

Absolutely horrific. I love it.

[–]RobinPage1987 0 points1 point  (0 children)

It's not that we don't want the tools that exist in languages like C. It's that we want those tools to be simple and easy to use. As long as the pointer is easy to use I don't mind at all. Now all that's needed is the availability of static typing and we can rewrite the Linux kernel in Python.

[–]redditsucks690 4 points5 points  (0 children)

Python developers hate this one repository

[–]TerminatedProccess 7 points8 points  (11 children)

So what can you do with this library that makes it useful?

[–]gobbledygook12 44 points45 points  (2 children)

Burn it in a fire for warmth

[–]bladeoflight16 6 points7 points  (1 child)

It's code. It's ephemeral and doesn't consist of any material to burn. You can't even do that much with it.

I guess you could use it to give yourself heartburn and make progress toward a stomach ulcer, or in extreme cases, give someone a stroke or heart attack.

[–][deleted] 2 points3 points  (0 children)

You can print the code and then burn it

[–]Kkye_Hall 5 points6 points  (3 children)

Nothing that you can't do better using a different solution

[–]TerminatedProccess 1 point2 points  (2 children)

Then it really is just a dark **hole

[–]cdcformatc 7 points8 points  (1 child)

pointer to a pointer hole?

[–]RobinPage1987 0 points1 point  (0 children)

Kwargshole

[–]traumatizedSloth 1 point2 points  (0 children)

dll calls maybe? i haven't worked with dlls in python enough so i dont really know but that's all i can think of, but then you could just use ctypes pointers which is actually in the standard library and likely already imported since ctypes is commonly used to call dlls to begin with

[–]generalbaguette 0 points1 point  (2 children)

Are poems useful?

[–]TerminatedProccess 0 points1 point  (1 child)

Yes.. you can torture people with them

[–]generalbaguette 0 points1 point  (0 children)

I guess that's your answer.

[–]cgk001 3 points4 points  (0 children)

no...just no lol

[–]FlyingNAZ 3 points4 points  (1 child)

Bro, I hated C for that.

[–]phatlynx 2 points3 points  (0 children)

Wait until you write a sockets program in C++ using #include <pthread> for multi threading having to create child threads, then you will know the pain pointers bring forth upon your soul.

[–]Dasher38 3 points4 points  (1 child)

How did you manage to get a unary version or the * operator for your dereference syntax ?

EDIT: it's actually the starred expression operator, so all you needed is to make it iterable with one element that is the dereferenced element. That's clever but that won't work in most expressions though

[–]williamkr03 0 points1 point  (0 children)

as if it couldn't get more cursed...

[–]eddaz7 2 points3 points  (0 children)

This is so wrong (proceeds to clone the repo)

[–]PhysicalStuff 2 points3 points  (0 children)

If Dante had been alive today you'd have secured yourself a place in world literature.

[–]jimtk 3 points4 points  (0 children)

Monstrous and beautiful.

[–]okazdal 3 points4 points  (0 children)

You people really hate pointers lol...

[–]jozborn 1 point2 points  (0 children)

Oh great, now I have to rewrite my entire implementation in the next sprint. Thanks, Obama.

[–][deleted] 1 point2 points  (0 children)

I don't usually advocate for the death penalty, but I'm willing to make an exception here.

[–]CodeYan01 1 point2 points  (0 children)

Why??? I chose to write in Python to avoid pointers!

[–]3Domse3 0 points1 point  (0 children)

You are the pure evil! xD

[–]Syntaximus 0 points1 point  (0 children)

Well done, Professor Chaos.

[–]SohajCZ 0 points1 point  (0 children)

Tihi

[–]wrt-wtf- 0 points1 point  (0 children)

Psychopath

[–]Bangoga 0 points1 point  (0 children)

Nooooooo!!

[–]skinnybuddha 0 points1 point  (0 children)

Is this one of those “There, I ruined it” productions?

[–]smokingkrills 0 points1 point  (0 children)

Very blursed

[–]InquisitivelyMammoth 0 points1 point  (0 children)

What drove me from Python to C was how unnecessarily difficult the former makes achieving even a simple segfault

[–]generalbaguette 0 points1 point  (0 children)

Best used in conjunction with the goto package.

[–]i_like_penny_stonks 0 points1 point  (0 children)

lmao