JuliaPy / JuliaPy/PyCall.jl

Intern frequently used PyObject?

Ouverte
#259 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Julia
Étoiles
1.5k
Forks
186
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

While examing the `gc` of my code I saw a LOT of PyObject being created and garbage collected. (I modified `PyCall` so as to print the object at finalizing)

I am wondering if `PyCall` can automatically cache many frequently used objects, such as

```
PyObject([])
PyObject(None)
PyObject(True)
PyObject(False)
```

and maybe even `PyObject(0), ... PyObject(255)`.

For example, I have a [Julia wrapper](https://github.com/colinfang/PyLogging.jl) for python `logging`. Each logging would generate 7 `PyObjects`. That's a bit too many.

```
julia> PyLogging.basicConfig()

julia> @warning logger "ll"
WARNING:root:ll

julia> gc()
"Start pydecref PyObject (30,)"
"Start pydecref PyObject True"
"Start pydecref PyObject 30"
"Start pydecref PyObject 'll'"
"Start pydecref PyObject []"
"Start pydecref PyObject (30, 'll', [])"
"Start pydecref PyObject None"
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start by inspecting PyCall's PyObject construction and finalization paths, especially the constructors for None, booleans, empty lists, tuples, and small integers. Determine how frequently created objects could be cached without breaking reference management, then verify that repeated logging calls create fewer temporary PyObjects and still finalize safely.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
julia, python
Domaine
backend, performance
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.