Skip to content

Commit

Permalink
feat: use ccreate_task for ASyncSorter (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 29, 2024
1 parent 0da5042 commit 5840cab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions a_sync/iter.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ from typing import _GenericAlias, get_args

from async_property import async_cached_property

import a_sync.asyncio
from a_sync._typing import *
from a_sync.a_sync._helpers cimport _await
from a_sync.asyncio.create_task cimport ccreate_task_simple
from a_sync.exceptions import SyncModeInAsyncContextError


Expand Down Expand Up @@ -720,11 +720,15 @@ class ASyncSorter(_ASyncView[T]):
if self.__aiterator__:
async for obj in self.__aiterator__:
items.append(obj)
sort_tasks.append(a_sync.asyncio.create_task(self._function(obj)))
sort_tasks.append(
ccreate_task_simple(self._function(obj))
)
elif self.__iterator__:
for obj in self.__iterator__:
items.append(obj)
sort_tasks.append(a_sync.asyncio.create_task(self._function(obj)))
sort_tasks.append(
ccreate_task_simple(self._function(obj))
)
for sort_value, obj in sorted(
zip(await asyncio.gather(*sort_tasks), items),
reverse=reverse,
Expand Down

0 comments on commit 5840cab

Please sign in to comment.