Hello and welcome to this weeks blog post! As we’ve learned some basics about Python games and utilizing PyQt5 as a Graphical User Interface (GUI), we’re going to compare two sets of Python game code.
The first set of code derives from Al Sweigart’s Chatper 2 regarding Pygame basics, which can be found here: http://inventwithpython.com/pygame/chapter2.html. The second set of code derives from USF professor Alon Friedman, which can be found here: https://github.com/AlonFriedman01/Python-class-2020/blob/master/Module%20%23%2012.py.
Neither code example actually references each other, meaning they do not implement the same program utilizing different techniques. Instead they are completely different sets of code altogether. For that I found it a little difficult to compare the two code sets side by side. That being said, I have been requested to evaluate the use if Python module Pickle, which is utilized in Professor Friedman’s code example.
The Pickle Python module is purposed as a serializing and deserializing binary data into objects within the program. The term pickling is when a binary stream is deserialzed into a Python object. And unpickling is then a Python object is serialized into a binary stream.
While the need for serializing and deserializing binary data to and from Python objects to and from binary streams does exist. Per the Python organizations website referring to the Pickle module, they state it is not secure and could open your application for easy malicious attacks. While there is a possible hashing protocol you leverage in addition to the Pickle module. Python’s site suggests a more suitable serializing and deserializing package; namely JSON (JavaScript Object Notation). The main benefit in this approach is JSON does not allow for malicious code injection via unsecured data packets being unpickled.
For the above reasons I would prefer the implementation of Al Sweigart’s non Pickle module Pygames.
That wraps up this weeks blog posting. Thanks for stopping by and reading. For more information about Python game coding and the PyQt5 library, check out these links: