Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup audb.Dependencies to list conversions #362

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions audb/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __getitem__(self, file: str) -> typing.List:
list with meta information

"""
return list(self._df.loc[file])
return self._df.loc[file].tolist()

def __len__(self) -> int:
r"""Number of all media, table, attachment files."""
Expand All @@ -118,7 +118,7 @@ def attachments(self) -> typing.List[str]:
list of attachments

"""
return list(self._df[self._df["type"] == define.DependType.ATTACHMENT].index)
return self._df[self._df["type"] == define.DependType.ATTACHMENT].index.tolist()

@property
def attachment_ids(self) -> typing.List[str]:
Expand All @@ -128,7 +128,9 @@ def attachment_ids(self) -> typing.List[str]:
list of attachment IDs

"""
return list(self._df[self._df["type"] == define.DependType.ATTACHMENT].archive)
return self._df[
self._df["type"] == define.DependType.ATTACHMENT
].archive.tolist()

@property
def files(self) -> typing.List[str]:
Expand All @@ -138,7 +140,7 @@ def files(self) -> typing.List[str]:
list of files

"""
return list(self._df.index)
return self._df.index.tolist()

@property
def media(self) -> typing.List[str]:
Expand All @@ -148,7 +150,7 @@ def media(self) -> typing.List[str]:
list of media

"""
return list(self._df[self._df["type"] == define.DependType.MEDIA].index)
return self._df[self._df["type"] == define.DependType.MEDIA].index.tolist()

@property
def removed_media(self) -> typing.List[str]:
Expand All @@ -158,12 +160,9 @@ def removed_media(self) -> typing.List[str]:
list of media

"""
return list(
self._df[
(self._df["type"] == define.DependType.MEDIA)
& (self._df["removed"] == 1)
].index
)
return self._df[
(self._df["type"] == define.DependType.MEDIA) & (self._df["removed"] == 1)
].index.tolist()

@property
def table_ids(self) -> typing.List[str]:
Expand All @@ -187,7 +186,7 @@ def tables(self) -> typing.List[str]:
list of tables

"""
return list(self._df[self._df["type"] == define.DependType.META].index)
return self._df[self._df["type"] == define.DependType.META].index.tolist()

def archive(self, file: str) -> str:
r"""Name of archive the file belongs to.
Expand Down
Loading