We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Dynamic Class Generation in Python

Formal Metadata

Title
Dynamic Class Generation in Python
Title of Series
Part Number
4
Number of Parts
169
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Kyle Knapp - Dynamic Class Generation in Python This talk is about dynamic class generation in python: the practice of writing code that generates classes and their functionality at runtime. It will use boto3, the AWS SDK for Python, as a basis to dive into the basics, the benefits, and the drawbacks to dynamically generating classes. ----- This talk is about the concept of dynamic class generation in python. The whole idea is writing code that generates classes and their functionality at runtime. You now may be asking yourself, “That sounds like a neat trick. Why would I ever generate my classes at runtime?” Here are a few reasons why: - It can decrease the physical size of your code. - It can improve the workflow in adding new functionality. - It can improve reliability of your code. One example where the power of this concept has really been leveraged is in boto3, the AWS SDK for Python. Dynamic class generation has allowed boto3 to become heavily data driven such that most of its classes and methods are generated based off JSON models representing aspects of an AWS service’s API. For example, to add support for a new AWS service API in boto3, just plop in a JSON file into the library with no additional Python code required. Using lessons and techniques drawn from developing boto3, this talk will dive into the following topics related to dynamic class generation: - The basics of dynamic class generation such as how to effectively dynamically generate classes. - How to overcome some of the challenges of dynamic class generation. - The tradeoffs in dynamically generating classes and discussion on when it is appropriate.