-
Book Overview & Buying
-
Table Of Contents
Supercharged Coding with GenAI
By :
GitHub Copilot functions as a personalized AI assistant, predicting our next coding moves. Because LLMs excel at imitating style, Copilot quickly adapts to any style preferences it observes during a session.
For example, suppose we have a file named ch8/code_samples/math_calculations.py with two functions (get_area and get_arithmetic_mean), both implemented without type hints and with single-line function signatures:
import numpy as np
def get_area(radius):
return np.pi * radius ** 2
def get_arithmetic_mean(x1, x2):
return (x1 + x2) / 2
If we then start typing a new function signature for get_euclidean_distance, Copilot is likely to generate an implementation in the same style, with no type hints and one-line signatures, as shown in Figure 8.3:

Figure 8.3: Copilot preserving our coding style
Alternatively, if our code implements type hints, hanging indents, and docstrings, Copilot will generate suggestions...