Live data from Hacker News

Pointers and Memory Management in Python

github.com

21–30 of 39 posts

Re: Pointers and Memory Management in Python

#21
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.

They're a good tool for sure, but I take issue with your characterization. It's not "laziness" or "lack of understanding" that makes them ill-suited for python, but just that they're too expressive for the goals python seeks to fulfill.

I suspect that people's aversion to manual memory management is more an expression of that semantic mismatch rather than some kind of reveling in their own stupidity.

Re: Pointers and Memory Management in Python

#22
post #20
post #5

Why not? Because pointers are broken and harmful.

if you don’t understand how to use pointers you probably shouldn’t be writing software.

Respectfully I disagree. Machines with heap are not the only model of computation, and the fact that useful software has been written in python suffices to prove this.

I mean... are we to throw away all code in numerical methods because the canonical, automatic memory management is good enough for most professionals?

Re: Pointers and Memory Management in Python

#25
post #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.

One small step towards Fortran

Re: Pointers and Memory Management in Python

#29
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.

They're a good tool for sure, but I take issue with your characterization. It's not "laziness" or "lack of understanding" that makes them ill-suited for python, but just that they're too expressive for the goals python seeks to fulfill. I suspect that people's aversion to manual memory management is more an expression of that semantic mismatch rather than some kind of reveling in their own stupidity.

[deleted]

Re: Pointers and Memory Management in Python

#30
post #18
post #17

Earlier quoted context omitted.

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.

I wouldn't cast 'I don't want to do this because I need to be careful' as laziness, it's just being smart/pragmatic. Take that statement in the context of home grown cryptography instead of pointes and it'll make sense. People might have different thresholds for the need to be careful.

Also, with regards to 'I don't need/want to understand what's going on as long as it works' ...isn't not needing to understand the implementation the entire point of creating abstractions?

Post reply on HN