Commit 5a59c4e
authored
DOC: Annotate
* Update lib.py
Replacing pd.DataFrame with Generator[pd.DataFrame, None, None]
The reason for replacing pd.DataFrame with Generator[pd.DataFrame, None, None] is to better reflect the actual output type of the random_ohlc_data function. Here are the specific reasons and benefits:
Reasons:
Accuracy of Output Type: The original code declared that the function returns a pd.DataFrame, but in reality, the function is a generator that yields multiple pd.DataFrame objects. Using Generator more accurately describes the function's behavior.
Clarity of Type Hinting: Using Generator allows the code readers and users to more easily understand that the function returns a generator rather than a single DataFrame. This helps prevent potential misunderstandings and misuse.
Benefits:
Performance Improvement: Generators can generate data on-demand rather than generating all data at once, saving memory and improving performance, especially when dealing with large datasets.
Lazy Evaluation: Generators allow for lazy evaluation, meaning data frames are only generated when needed. This can improve the efficiency and responsiveness of the code.
Better Code Maintainability: Explicitly using generators makes the intent of the code clearer, enhancing readability and maintainability, making it easier for other developers to understand and maintain the code.
* Import typing.Generatorlib.random_ohlc_data() as a Generator (#1162)1 parent 4b829b7 commit 5a59c4e
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| |||
0 commit comments