From 2d87194cdd999cc192ff7042f3500011fa59286f Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 12 Jan 2021 14:16:27 -0600 Subject: [PATCH] Optimize determination of number of segments in API.chunked_upload --- tweepy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tweepy/api.py b/tweepy/api.py index d62b222..a675b94 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -296,7 +296,7 @@ class API: chunk_size = kwargs.pop('chunk_size', DEFAULT_CHUNKSIZE) chunk_size = max(min(chunk_size, MAX_CHUNKSIZE), MIN_CHUNKSIZE) - segments = int(file_size / chunk_size / 1024.0) + (1 if file_size % chunk_size > 0 else 0) + segments = file_size // (chunk_size * 1024) + bool(file_size % chunk_size) for segment_index in range(segments): # The APPEND command returns an empty response body -- 2.25.1