Skip to content
The Chat Archive
chatglm3-6b Arena Human Preference 55K

Optimize the following code. def polllro( self, operations: List[Operation]) -> None:…

  1. User

    Optimize the following code.

    def _poll_lro( self, operations: List[Operation]) -> None: """ Polls the long running operations. """ start_time = time.time()

        while True:
            status = [exponential_backoff(op.done) for op in operations]
    
            if all(status):
                print("Completed!")
                break
    
            print(f"{sum(status)}/{len(status)} completed")
            time.sleep(60)
    
        end_time = time.time()
    
        print(f"Time taken: {end_time-start_time} secs")
    
  2. Assistant

    def _poll_lro(operations: List[Operation]) -> None: """ Polls the long running operations. """ start_time = time.time()

    while True:
        status = [op.done for op in operations]
    
        if all(status):
            print("Completed!")
            break
    
        print(f"{sum(status)}/{len(status)} completed")
        time.sleep(60)
    
    end_time = time.time()
    print(f"Time taken: {end_time-start_time} secs")
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.

Identical first prompt