Python Multi-Media API (PMMA)

By Thomas Jebson
(2024 - Currently In Development)
Personal Project
Back to portfolio

Skills & Technologies Used

Python C++ GitHub Visual Studio Visual Studio Code CMake

Supported Platforms

Windows Linux

Links


About

PMMA is a currently in development Python library that provides a high-level interface for developing multi-media applications.

PMMA achieves this by providing a variety of sub-components that handle different aspects of multi-media application development, such as 2D graphics rendering, audio processing, input handling, and more. Each sub-component is designed to be modular and extensible, allowing developers to easily integrate them into their projects and customize them to fit their specific needs. Furthermore, careful attention has been given to ensure each sub-component is highly-optimised, with large portions of the API being written in C++ and a Python interface provided by Cython to ensure maximal performance.

The philosophy behind PMMA is to provide a simple and intuitive API developers can use to quickly start developing their applications without needing to worry about optimising how their code interacts with PMMA. A good example of this is PMMA's dynamic batching of draw calls in the rendering API. This allows multiple shapes to be rendered with a single draw call - significantly improving performance whilst being completely transparent to the end developer.

Performance

With PMMA being described as a 'highly optimised API' in my portfolio, I thought it would be useful to provide some insight into the performance of PMMA and how it compares to other similar libraries.

These tests were performed on a Windows 11 machine with an AMD Ryzen 7 5800X CPU, 32 GB of RAM and an AMD Radeon RX 7700 XT GPU.
Below are some results comparing PMMA's rendering performance to Pygame and Pyglet in Python 3.10. Pygame and Pyglet were chosen for comparison as they are two of the most popular Python libraries for 2D graphics rendering currently. In this test, one hundred thousand (100, 000) color changing circles are rendered to the screen every frame, with the average frames per second (FPS) being recorded across 50 frames, with the results being as follows:

Benchmark One Graph
As can be seen from the graph, PMMA significantly outperforms both Pygame and Pyglet in this test. Whilst not a direct indication of simplicity, PMMA achieved this in: 34 lines of code, compared to 78 for Pygame and 67 for Pyglet. That test was performed on the latest developmental version of PMMA (v5.1.0). This same test was performed in C++ comparing PMMA against RayLib, SFML and the results were as follows:

Benchmark Two Graph
Please note: These performance comparisons is not designed to imply any of the other libraries that were tested against are 'bad' in any way. They all serve a purpose and currently PMMA overlaps this heavily. In future versions there will be more of a distinction between PMMA and other libraries, with PMMA moving onto widgets and 3D graphics in the near future.

Please note: This test was devised by a third party with no knowledge of programming. Therefore bias towards the strengths of a specific API has been minimised as much as possible.

Reflection

PMMA is one of my most ambitious and important projects to date. Development on the API began when I noticed when developing games in Python I was continually implementing the same features and optimisations across multiple projects. Fed up of this, I decided to combine these commonly used components together into a single library that could be used across a variety of projects.

This process began long before the official development of PMMA began in around 2018 - however was very far away from what PMMA is today. Since then, the API has undergone several major revisions:
  • Switching from extending Pygame as an existing graphics API to ModernGL (an OpenGL wrapper for Python) and creating custom graphics.
  • Moving a large portion of the API from Python to C++ for dramatically improved performance and native OpenGL support.
  • Reworking the entire rendering API to use BGFX instead of OpenGL as a better long term support strategy for the API.
Just to name a few of the major changes that have been made to PMMA over the years. Since starting my University course in 2024, I have been able to apply directly my improved knowledge and research of C++ and more aggressive optimisation strategies to PMMA, which has resulted in dramatic performance and memory usage improvements across the API. Since I started my course, I have also been able to use PMMA as a rendering engine to generate artwork and prototype game ideas and designs before bringing them into Unity or Unreal Engine for further development.

PMMA is currently still in active development and is going through major changes as the API continues to be migrated further into C++ from Python, with an increasingly high standard of code quality and reliability being maintained across the API. Furthermore, PMMA is also in the process of getting formal documentation (a lengthly process for a project of this size) and the development of the API is increasingly giving me more experience in project management and software development best practices.

Overall, PMMA is a project I am very proud of and has been a great learning experience for me. I am excited to continue developing PMMA in the near future, and also plan to begin using it to develop my own games for game jams and personal projects in the near future, which which will help draw attention to the API. I have a long list of features, many of which have been prototyped and are in active development for the API and I am comitted to continuing to maintain and develop PMMA for the foreseeable future.