vaefremov95 commented on code in PR #60963:
URL: https://github.com/apache/airflow/pull/60963#discussion_r2730825074


##########
providers/imap/src/airflow/providers/imap/hooks/imap.py:
##########
@@ -240,12 +260,17 @@ def _retrieve_mails_attachments_by_name(
 
         return all_matching_attachments
 
-    def _list_mail_ids_desc(self, mail_filter: str) -> Iterable[str]:
+    def _list_mail_ids_desc(self, mail_filter: str, max_mails: int | None = 
None) -> Iterable[str]:
         if not self.mail_client:
             raise RuntimeError("The 'mail_client' should be initialized 
before!")
         _, data = self.mail_client.search(None, mail_filter)
         mail_ids = data[0].split()
-        return reversed(mail_ids)
+        mail_ids_desc = reversed(mail_ids)

Review Comment:
   Hello!  
   As the author of the original issue/solution, I’d like to clarify my chain 
of thought.  
   
   In my understanding of Python, reversed() combined with itertools.islice() 
does not reorder or sort the list, it simply returns a reverse iterator and 
accesses only the required elements. These operations do not create new lists 
in memory, unlike a simple slice ([:]), which allocates a new list. 
   
   I’d be glad to hear additional opinions on this topic!
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to