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.3.tar.gz (4.5 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.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for s3_ls-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f574cd7986d5f7a8e2fa65bc00b04b1f2e4b6ce49a188b1bea4411bcbdac0495
MD5 9b2df84b9506882475ace4bc48b84b52
BLAKE2b-256 64de7b0430e764771ca9fd816ac42f7965c835be8de9c4d17fd8f6b464f217ae

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for s3_ls-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5fe667c25200d360648c5100b0c520176fbe083e19d4733100cb70a4da35293b
MD5 801b653d85f6e61dc00eb1a11a6e5539
BLAKE2b-256 77ae967409535672e03927c139048d3835b8efc3bb5c8f7ae6fadc2223949e08

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