FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ZeroIntensity/pointers.py at d43bf1511e1144d8f9e73c5eebb2bde5ed715c60 · GitHub

Repository navigation

About

Bringing the hell of pointers to Python.

Topics

Resources

Contributing

Stars

936 stars

Watchers

6 watching

Forks

Repository files navigation

pointers.py

Bringing the hell of pointers to Python

Why would you ever need this

Examples

from pointers import _

text: str = "hello world"
ptr = _&text  # creates a new pointer object
ptr <<= "world hello"
print(text)  # world hello
from pointers import c_malloc as malloc, c_free as free, strcpy, printf

ptr = malloc(3)
strcpy(ptr, "hi")
printf("%s\n", ptr)
free(ptr)

Features

  • Fully type safe
  • Pythonic pointer API
  • Bindings for the entire C standard library
  • Segfaults

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
  • Makes it very easy to manipulate memory in Python
  • Why not?

Installation

Linux/macOS

python3 -m pip install -U pointers.py

Windows

py -3 -m pip install -U pointers.py

About

Bringing the hell of pointers to Python.

Topics

Resources

Contributing

Stars

936 stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL