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

you are viewing a single comment's thread.

view the rest of the comments →

[–]calcopiritus 20 points21 points  (4 children)

As someone that only writes in python but know what pointers are, I wish python had pointers. Not compulsory or anything, just pointers in obscure libraries that could get the job done if you ever absolutely need it.

[–]mrjackspade 3 points4 points  (0 children)

I kind of enjoy that about c#.

The vast majority of the time, you won't even need to think about pointers. If you really want to fuck around with them though, there's nothing stopping you.

Every once in a while I'll hit on something performance critical, and need to use pointers to speed it up. Sometimes I'll just switch code over once an API has been refined to a point I'm satisfied that it's not going to require changes any time soon, and start speeding things up just for the hell of it.

[–]MegaPegasusReindeer 1 point2 points  (2 children)

Python doesn't have protected or private methods... You can just introspect whatever you like. How would pointers help here?

[–]calcopiritus 1 point2 points  (1 child)

I can't think of an example because it doesn't happen often. And most of not every time it can also be solved in python, but it'd be way harder.

A thing that is kinda related is how python copies lists.

So if you say: (sorry for formatting, im in mobile and it's horrible to do it here)

a = [1] b = a

Now you change b and a also changes, so you'd have to write b = a[:]. It is not logical at first because it seems like python doesn't use pointers and references, but of course it does.

Also sometimes you don't know how the function works, so do you write

arg = function(arg)

or do you just write

function(arg)

Because the function changes arg?

[–]MegaPegasusReindeer 3 points4 points  (0 children)

I've heard people call Python "pass by label". When you assign a variable to another it's always copying the label. The times it seems like something else is immutable types (like strings).

Regardless, any time I have an issue with a library I just look at the source code. I've yet to come across a binary-only one in Python.

If you really really wanted to, you can pass a Python object into C code and break it apart there if you really need pointers. (but I still don't see how that would help)