Article is mostly fine, but the author does some effort to mention CPython-specific things, but not consistently, making it a bit of a confusing read for when you've worked with different Python implementations at the implementation level (C in my case). E.g. Each object contains at least three pieces of data: Reference count well, in CPython yes but not in implementations which use mark and sweep GC.
I don't think there's a reason why support for pointers can't be added as a package, perhaps one that integrates with ctypes. It could function like PEEK and POKE in the old BASIC interpreters. However, accessing storage as a base plus offset, if desired, could be implemented with numpy arrays.
Yes, but pointers are more basic, since Python's internal references participate in garbage collection.
If you would use pointers exclusively, then you'd have to write your own garbage collector. Also, accessing data would be more difficult, and you could not use Python's data types such as classes.
Perhaps this is a novice question, but what is an instance where one would need to use pointers in python? I am having trouble thinking of an instance where I would need to do this.
IINM the reference implementation has a cache for small integers. I wonder what happens if you try the ctypes example in the article with one of the cached integers.
[+] [-] svat|6 years ago|reply
• Facts and myths about Python names and values https://nedbatchelder.com/text/names.html
and its presentation version:
• Python Names and Values https://nedbatchelder.com/text/names1.html
[+] [-] stinos|6 years ago|reply
[+] [-] randomvectors|6 years ago|reply
[+] [-] Thorrez|6 years ago|reply
[+] [-] analog31|6 years ago|reply
[+] [-] unknown|6 years ago|reply
[deleted]
[+] [-] ForHackernews|6 years ago|reply
[+] [-] amelius|6 years ago|reply
If you would use pointers exclusively, then you'd have to write your own garbage collector. Also, accessing data would be more difficult, and you could not use Python's data types such as classes.
[+] [-] frankbreetz|6 years ago|reply
[+] [-] Thorrez|6 years ago|reply
[+] [-] sametmax|6 years ago|reply
[+] [-] bigiain|6 years ago|reply
[+] [-] tinalumfoil|6 years ago|reply
So if I write
My linked list won't get cleaned up? I think the author should be more careful with his wording.[+] [-] unknown|6 years ago|reply
[deleted]
[+] [-] scardine|6 years ago|reply
[+] [-] scardine|6 years ago|reply
[+] [-] knome|6 years ago|reply
https://kate.io/blog/2017/08/22/weird-python-integers/ http://hforsten.com/redefining-the-number-2-in-python.html
I found these offhand, but I'm pretty sure I saw this trick earlier than 2017.
[+] [-] tells|6 years ago|reply