Skip to content

Commit 69ee12c

Browse files
committed
refactor_examples: remove unnecessary json.dumps in get_book example
- Update the get_book example function in the README to return a dictionary directly instead of JSON string - This change simplifies the example and avoids potential performance overhead from unnecessary serialization
1 parent 455230e commit 69ee12c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ For example, the `pool` argument in the following function is not serializable:
738738
def get_book(pool: ConnectionPool, book_id: int):
739739
connection = pool.get_connection()
740740
book = connection.execute("SELECT * FROM books WHERE book_id = %s", book_id).fetchone()
741-
return json.dumps(book.to_dict())
741+
return book.to_dict()
742742
```
743743
744744
However, we can exclude the `pool` argument from the key and hash calculations, so the function can be cached:

0 commit comments

Comments
 (0)