Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Python] Compiler annotations for ownership semantics

Aperta
#21,618 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@aaronj0 ci sta già lavorando.

Dal 16/3/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

in:Python Interface new feature
Feature description

It would be great if ownership semantics can be communicated in the C++ source code via annotations, so we don't have to write Pythonizations by hand just for this, and carefully keep them in sync with the behavior of the C++ code.

This is relevant for both arguments and return values.

For arguments, we need something to indicate ownership adoption (_transfer_ownership is just a placeholder name to illustrate the idea):

void foo(TObject * _transfer_ownership obj) {
   std::unique_ptr<TObject>{obj};
}

For return values, we need something to indicate ownership on the caller side (_caller_owns is again just a placeholder):

TObject *_caller_owns bar() {
   return new TObject{};
}

Object ownership problems come up often on the forum (example post), so having a robust way to convey the correct ownership semantics would be a game changer for the robustness of the ROOT Python interfaces.

Alternatives considered
  • Manual Pythonizations like in ee79dfd85c2f, but this doesn't scale well.
  • Migrating C++ interfaces to smart pointers, but this would break backwards compatibility.
Lingua principale
C++
Stelle
3.3k
Fork
1.6k
Merge medio
2g 16h
PR unite (30g)
194

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di root-project/root

Tutte le issue di root-project/root

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.