Live data from Hacker News

Pointers and Memory Management in Python

github.com

11–20 of 39 posts

Re: Pointers and Memory Management in Python

#11
post #6

Earlier quoted context omitted.

Once compiled to assembly, every data is accessed via pointers. Every data structure is represented with pointers. Almost everything is a pointer. According to you, all softwares are broken and harmful? Programming languages can provide a safe interface to pointers (just like Rust do with `Box `, `Rc `, `Arc `, or C++ in some ways with `shared_ptr ` and `unique_ptr `). Also, "Why not?" here clearly means "I did it fo…

You could extrapolate this right down to the binary layer. Are lower level technology’s more dangerous, no. Are they more difficult to get right? Yes. Do we want to stop worrying about finicky correctness or pointers and worry about building more complex things? Probably yes also.

> Do we want to stop worrying about finicky correctness or pointers and worry about building more complex things? Probably yes also.

Which is why I mentioned the safe higher-level interfaces provided by programming languages.

Yet, I think it's important to learn about the lower level technology to better understand the higher level technology.

And definitely stop spitting on lower level technologies.

Re: Pointers and Memory Management in Python

#12
post #8
post #6

Earlier quoted context omitted.

Once compiled to assembly, every data is accessed via pointers. Every data structure is represented with pointers. Almost everything is a pointer. According to you, all softwares are broken and harmful? Programming languages can provide a safe interface to pointers (just like Rust do with `Box `, `Rc `, `Arc `, or C++ in some ways with `shared_ptr ` and `unique_ptr `). Also, "Why not?" here clearly means "I did it fo…

Cmon. In a good faith reading, he means as a matter of developer access. And he's not wrong as concerns what 90+% of devs have to get done at their jobs.

Yes pointers are hard to get right. No, depicting it as "broken and harmful" is not ok, even with good faith reading.

Re: Pointers and Memory Management in Python

#13
post #6

Earlier quoted context omitted.

Once compiled to assembly, every data is accessed via pointers. Every data structure is represented with pointers. Almost everything is a pointer. According to you, all softwares are broken and harmful? Programming languages can provide a safe interface to pointers (just like Rust do with `Box `, `Rc `, `Arc `, or C++ in some ways with `shared_ptr ` and `unique_ptr `). Also, "Why not?" here clearly means "I did it fo…

Its the same crowd that goes screeching when they see „goto“ eyeroll

Wait until you see people saying "exceptions are glorified goto".

Basically, every statement of the form "X is broken and harmful" either don't understand X, or have read it somewhere else without giving a second thought.

X exists because it had some use at some point. Y and Z are implemented thanks to X. Now we no longer need to do X by hand. This does not make it broken nor harmful.

Re: Pointers and Memory Management in Python

#15
Cool project, did you learn anything interesting from implementing it?

I think I see that the malloc functionality is provided by some DLLs that you import: https://github.com/ZeroIntensity/pointers.py/blob/master/src... I haven’t tried that yet any lessons learned on that or was it pretty straightforward to import some DLLs and start using them in python?

Re: Pointers and Memory Management in Python

#16

Ok now this truly awful print(1, 2) # prints "2 2" Pointers are bad but this implementation is broken. There is no way to do this using pointers IRL.

1 and 2 are objects in Python. You can change the field corresponding to the int value of the field for the object pointed to by 1. Even worse small ints are cached, so now you have changed 1 for the entire interpreter.

Re: Pointers and Memory Management in Python

#17
post #4

I don’t understand the problem people have with pointers, they are an amazing tool. And the negative attitude towards manual memory allocation just seems like laziness to me and even suggests a lack of understanding for both what you’re doing and how computers work.

Laziness is one of the cardinal virtues of a programmer.

Re: Pointers and Memory Management in Python

#18
post #17
post #4

I don’t understand the problem people have with pointers, they are an amazing tool. And the negative attitude towards manual memory allocation just seems like laziness to me and even suggests a lack of understanding for both what you’re doing and how computers work.

Laziness is one of the cardinal virtues of a programmer.

There is good laziness:

  - Don't Repeat Yourself
  - Don't Reinvent the Wheel
  - ...
And bad laziness:

  - I don't want to do this because I need to be careful
  - I don't need/want to understand what's going on as long as it works
  - ...
The latter is what leads to most issues/bugs.
Post reply on HN