Understanding which Python features are supported by Shed Skin
Shed Skin supports a substantial subset of Python, but not all features can be compiled to C++. This page documents what works, what doesn’t, and workarounds where available.
These features rely on runtime introspection which cannot be determined at compile time. Since Shed Skin must generate static C++ code, it cannot support these dynamic operations.
# Not supported: *args and **kwargsdef function(*args): # Error passdef function(**kwargs): # Error pass# Not supported: Unpacking in callsargs = [1, 2, 3]function(*args) # Error
Workaround: Use explicit parameter lists or container arguments:
# Good: Use explicit parametersdef function(arg1, arg2, arg3): pass# Good: Pass a list directlydef function(args): for arg in args: # process arg passfunction([1, 2, 3])
# Not supported: Nested function definitionsdef outer(): def inner(): # Error pass return inner# Not supported: Nested class definitionsclass Outer: class Inner: # Error pass
Workaround: Move nested definitions to module level:
Class attributes must always be accessed using the class name, not through instances:
class MyClass: class_attr = 42 def method(self): # Bad: Access through instance x = self.class_attr # Error # Good: Access through class name x = MyClass.class_attr
# Good: Static method accessclass Utils: @staticmethod def helper(): return "help"# Must use class nameresult = Utils.helper()Utils.some_static_method()
Always use the explicit class name when accessing class attributes or static methods. Instance-based access will cause compilation errors.
While lambda functions and function references work, they cannot be stored in containers (lists, dicts, etc.) and method/class references are not supported.
Avoid dynamic features: Stick to straightforward, static patterns
Test incrementally: Compile frequently to catch issues early
Use classes for state: Replace closures and nested functions with classes
Explicit over implicit: Use clear, direct code rather than clever tricks
If you try to use an unsupported feature, Shed Skin will typically report an error during compilation. Read error messages carefully—they often suggest workarounds.