Skip to main content

Fast S3 object listing

Project description

s3-ls

Fast S3 object listing

Introduction

Listing S3 directory containing millions of objects is very painful because it has to be sequential, but maximum number of objects per one request is limited to 1000.

# First 1k objects
response = s3.list_objects_v2(
    Bucket=bucket, Prefix=prefix, StartAfter=""
)
last_key = response["Contents"][-1]["Key"]

# Next 1k objects
response = s3.list_objects_v2(
    Bucket=bucket, Prefix=prefix, StartAfter=last_key
)
...

s3-ls parallelizes it by partitioning the prefix into multiple parts and listing them in parallel.

prefix = "path/to/dir/"

prefix_1 = "path/to/dir/a"
prefix_2 = "path/to/dir/b"
prefix_3 = "path/to/dir/c"
... (70 prefixes)

In this way, the listing process can be done 70x faster in the ideal case.

Quick Start

Installation

pip install s3-ls

Usage

s3-ls s3://bucket/prefix
from s3_ls import list_objects

for obj in list_objects(bucket, prefix, **s3_kwargs):
    key = obj["Key"]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3_ls-0.0.5.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s3_ls-0.0.5-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file s3_ls-0.0.5.tar.gz.

File metadata

  • Download URL: s3_ls-0.0.5.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for s3_ls-0.0.5.tar.gz
Algorithm Hash digest
SHA256 26d0b102748b0a4af89d0a583880a0f74726a8afbd6fc48edfb566ab828166e3
MD5 c553de18dd19a5216b2a5ef633a3e69f
BLAKE2b-256 1f0e9c2b141e6a29a26ce766829a8b1180fe287267af859efae32424d933b4f1

See more details on using hashes here.

File details

Details for the file s3_ls-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: s3_ls-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for s3_ls-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3ae9b709a7ef9eb2f20b9239e2d40953b635998b3afc222a7efee51a8253f023
MD5 05969796183e39e9cd3e5667c1ce8acc
BLAKE2b-256 e92f1be42c5cd93b0e296fd33ead229cf948bbceeaed5400cc5594da6946ea84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page