Requirement
Retrieve content from 20 google sheets within single Google spreadsheet.
How should we approach this?
- Retrieve list of all sheets as array
- Iterate over the array and retrieve content for each sheet
I asked Bing to get me python code to do so.
Prompt - code to make request
Write python code to get content of range a:a from all available sheets of google spreadsheet
Bing
This is okay, but what if you have 100 sheets within single spreadsheet.
Each request would be around 0.7 seconds, waiting time will be 100*0.7 = 700 seconds. around 11 minutes.
Follow up question to improve performance.
Prompt - improve performance
I am trying to retrieve result from 100 sheet_names array. is there a way you can improve performance of this code? Without giving any directions.
Bing
Looks good, it suggested me to use batch_get
function of googleapis.
However, what if endpoint or API you are trying to call is simply an http request to an api or endpoint?
Simplified Problem
Let's simplify problem statement
Retrieve users details for each users with id from 1 to 100
Prompt
generate python code to make HTTP request to API https://64217eb134d6cd4ebd74a672.mockapi.io/api/v1/users/{id} for, id from 1 to 30
Bing
Execution time: 13 seconds
Prompt
I am trying to retrieve information for 100 users, it is slow. can you improve performance?
Bing
Pretty cool π€, isn't it? Though now you need to know following things.
- Handle 429, rate limiting error
- The impact of multithreaded python script
FYI π
Typescript
Node is by default single threaded application and works on call back, since introduction of async-await, sometimes I see beginners use it to make their code synchronous.
Prompt
generate typescript code to make HTTP request using fetch to API https://64217eb134d6cd4ebd74a672.mockapi.io/api/v1/users/{id} for, id from 1 to 30
Bing
Execution time: 8.5 seconds
Prompt
It is slow, can you make all fetch in parallel?
Bing
Execution time: 0.6 seconds
Moral of the story
Start utilizing this AI based tools to enhance your productivity πβοΈ
Fun fact: cover image is created by bing.com/create
Top comments (0)