Skip to content

add missing python binding for filenames::file_name() - #8886

Merged
arvidn merged 1 commit into
RC_2_1from
filenames-py-bindings
Sep 21, 2026
Merged

arvidn merged 1 commit into
RC_2_1from
filenames-py-bindings

Conversation

@arvidn

@arvidn arvidn commented Sep 20, 2026

Copy link
Copy Markdown
Owner

No description provided.

@semanticdiff-com

semanticdiff-com Bot commented Sep 20, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  bindings/python/libtorrent/__init__.pyi  0% smaller
  bindings/python/src/file_storage.cpp Unsupported file format
  bindings/python/tests/torrent_handle_test.py  0% smaller
  include/libtorrent/file_storage.hpp Unsupported file format

@github-actions

Copy link
Copy Markdown

ABI check against v2.1.0

ABI additions detected (abidiff exit code 4), but they appear backwards compatible.

abidiff report
Functions changes summary: 0 Removed (2 filtered out), 0 Changed (477 filtered out), 2 Added (1 filtered out) functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
Function symbols changes summary: 0 Removed, 0 Added function symbol not referenced by debug info
Variable symbols changes summary: 0 Removed, 3 Added variable symbols not referenced by debug info

2 Added functions:

  [A] 'method virtual std::string libtorrent::ip_ban_alert::message() const'    {_ZNK10libtorrent12ip_ban_alert7messageB5cxx11Ev}
    note that this adds a new entry to the vtable of struct libtorrent::ip_ban_alert
  [A] 'function void libtorrent::truncate_files(const libtorrent::filenames&, const std::string&, libtorrent::storage_error&)'    {_ZN10libtorrent14truncate_filesERKNS_9filenamesERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_13storage_errorE}

3 Added variable symbols not referenced by debug info:

  [A] _ZTIN10libtorrent12ip_ban_alertE
  [A] _ZTSN10libtorrent12ip_ban_alertE
  [A] _ZTVN10libtorrent12ip_ban_alertE

@github-actions

github-actions Bot commented Sep 20, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Branchfilenames-py-bindings
Testbedubuntu-24.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
base-v1.torrent📈 view plot
🚷 view threshold
44,334.31 ns
(-26.69%)Baseline: 60,477.24 ns
87,155.51 ns
(50.87%)
base-v2.torrent📈 view plot
🚷 view threshold
81,352.18 ns
(-23.54%)Baseline: 106,401.40 ns
148,610.13 ns
(54.74%)
dh_compute_secret📈 view plot
🚷 view threshold
33,008.29 ns
(-10.04%)Baseline: 36,691.98 ns
46,851.39 ns
(70.45%)
dh_handshake📈 view plot
🚷 view threshold
66,255.24 ns
(-9.43%)Baseline: 73,150.75 ns
94,580.11 ns
(70.05%)
dh_key_exchange📈 view plot
🚷 view threshold
33,109.00 ns
(-9.44%)Baseline: 36,560.00 ns
47,129.95 ns
(70.25%)
ip_filter: access, hit📈 view plot
🚷 view threshold
51.98 ns
(-20.46%)Baseline: 65.36 ns
89.08 ns
(58.35%)
ip_filter: access, miss📈 view plot
🚷 view threshold
51.38 ns
(-20.37%)Baseline: 64.52 ns
88.17 ns
(58.28%)
many-pad-files.torrent📈 view plot
🚷 view threshold
910,079.10 ns
(-22.23%)Baseline: 1,170,166.46 ns
1,605,435.01 ns
(56.69%)
merkle: compute root📈 view plot
🚷 view threshold
138,854.68 ns
(-40.36%)Baseline: 232,815.35 ns
523,342.24 ns
(26.53%)
merkle: create proof📈 view plot
🚷 view threshold
105.36 ns
(-19.56%)Baseline: 130.98 ns
169.91 ns
(62.01%)
merkle: validate proof📈 view plot
🚷 view threshold
1,648.80 ns
(-37.86%)Baseline: 2,653.48 ns
5,716.81 ns
(28.84%)
piece picker: add/remove near-seed📈 view plot
🚷 view threshold
171,800.21 ns
(-13.36%)Baseline: 198,303.27 ns
242,409.52 ns
(70.87%)
piece picker: add/remove seed📈 view plot
🚷 view threshold
24.81 ns
(-11.06%)Baseline: 27.90 ns
37.68 ns
(65.85%)
piece picker: break one seed📈 view plot
🚷 view threshold
107,324.24 ns
(-9.63%)Baseline: 118,754.96 ns
165,022.52 ns
(65.04%)
piece picker: get availability📈 view plot
🚷 view threshold
13,652.34 ns
(-19.61%)Baseline: 16,982.10 ns
25,122.57 ns
(54.34%)
piece picker: mark as downloading, high index📈 view plot
🚷 view threshold
81.04 ns
(-14.74%)Baseline: 95.04 ns
119.96 ns
(67.55%)
piece picker: mark as downloading, low index📈 view plot
🚷 view threshold
1,347.20 ns
(-14.65%)Baseline: 1,578.44 ns
2,271.61 ns
(59.31%)
piece picker: pick pieces, after dirty📈 view plot
🚷 view threshold
847,840.46 ns
(-9.99%)Baseline: 941,983.43 ns
1,253,959.68 ns
(67.61%)
piece picker: pick pieces, clean📈 view plot
🚷 view threshold
36.04 ns
(-16.02%)Baseline: 42.92 ns
51.97 ns
(69.36%)
piece picker: pick pieces, dense peer📈 view plot
🚷 view threshold
37.49 ns
(-13.25%)Baseline: 43.22 ns
52.71 ns
(71.14%)
piece picker: pick pieces, sparse peer📈 view plot
🚷 view threshold
227,549.90 ns
(-34.31%)Baseline: 346,378.34 ns
770,655.95 ns
(29.53%)
piece picker: piece priorities📈 view plot
🚷 view threshold
14,249.70 ns
(-21.22%)Baseline: 18,088.69 ns
23,620.29 ns
(60.33%)
piece picker: refcount bitfield, 1 bit set📈 view plot
🚷 view threshold
165,899.19 ns
(-12.16%)Baseline: 188,862.59 ns
248,278.24 ns
(66.82%)
piece picker: refcount bitfield, 10 bits set📈 view plot
🚷 view threshold
171,662.51 ns
(-9.45%)Baseline: 189,586.49 ns
252,169.25 ns
(68.07%)
piece picker: refcount bitfield, 200 bits set📈 view plot
🚷 view threshold
173,239.75 ns
(-10.12%)Baseline: 192,748.93 ns
249,231.47 ns
(69.51%)
piece picker: refcount bitfield, 49 bits set📈 view plot
🚷 view threshold
173,957.92 ns
(-8.90%)Baseline: 190,957.49 ns
251,415.04 ns
(69.19%)
piece picker: refcount bitfield, 50 bits set📈 view plot
🚷 view threshold
166,479.04 ns
(-12.58%)Baseline: 190,443.41 ns
252,592.72 ns
(65.91%)
piece picker: refcount bitfield, 5000 bits set📈 view plot
🚷 view threshold
168,119.87 ns
(-14.52%)Baseline: 196,686.07 ns
264,831.19 ns
(63.48%)
rc4_encrypt📈 view plot
🚷 view threshold
24,433.96 ns
(-21.53%)Baseline: 31,136.85 ns
45,384.38 ns
(53.84%)
🐰 View full continuous benchmarking report in Bencher

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Adds the missing Python binding for filenames.file_name(), with C++ support, type stubs, and tests.

Changes:

  • Adds the filenames::file_name() forwarding method.
  • Exposes file_name(index) in the Python API and stubs.
  • Tests renamed, unrenamed, and invalid-index behavior.
File Description
include/​libtorrent/​file_storage.hpp Adds the filenames view method.
bindings/​python/​src/​file_storage.cpp Registers the Python binding.
bindings/​python/​libtorrent/​__init__.pyi Adds the type-stub declaration.
bindings/​python/​tests/​torrent_handle_test.py Tests expected behavior and validation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Validate negative and out-of-range piece indices in the Python map_block wrapper.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)

Comment thread bindings/python/src/file_storage.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

@arvidn
arvidn merged commit 8775a6e into RC_2_1 Sep 21, 2026
81 checks passed
@arvidn
arvidn deleted the filenames-py-bindings branch September 21, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants