Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python refactor #1477

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

ledvinap
Copy link

@ledvinap ledvinap commented Nov 1, 2022

(For discussion)

  • Refactor python bindings a bit, fixing various problems leading to SEGFAULT
  • class passed to SwapOnVSync is returned on second call unmodified
  • FrameCanvas is recycled when python object is freed

Add support for FrameCanvas::Serialize:

  • Python class with Buffer Protocol is returned
  • It can be easily used to write to file etc. (and no copy is necessary)
  • Now read-only, but read-write should be safe and it will allow zero-copy writing to framebuffer
    • another option is to export Deserialize, possibly with Buffer Protocol interface, but performance will be slightly smaller

Solves problem when installing package directly from git (pipenv install
-e )
- Except NULL for cdefs (slightly optimizes performance)
- Handle reading NULLs from Options (caused segfault)
- Improve handling of parameters for char* options
  - accepts string-like objects, returns bytes()
- Use cython magic for __options
- Handle None as NULL in SwapOnVSync (allows wait for sync usage)
- Use C++ Canvas object to handle common operations
- Use @Property decorator syntax
- prevent creation of uninitialized objects from Python code (__new__)
- prevent cython classes without corresponding C++ class (raise
   exception on all paths that can cause it)
- Trace displayed FrameCanvas in SwapOnVSync
  - class passed to SwapOnVSync is returned on second call
- Recycle FrameCanvas when python object is freed
- FrameCanvas class keeps RGBMatrix alive (RGBMatrix is not deleted
   before FrameCanvas)
Export Serialize using Python Buffer Protocol

Currently only read-only view is supported
```
green = Color(0, 255, 0)
rgbmatrix.Fill(*green())
generated using:
python3 -m cython -3 --cplus *.pyx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant