You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add a cell construtor, and expose the cell type in Lib/types.py #80092
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2019-02-07.19:37:16.139>created_at=<Date2019-02-06.10:55:47.309>labels= ['type-feature', '3.8']
title='add a cell construtor, and expose the cell type in Lib/types.py'updated_at=<Date2019-02-07.19:37:16.138>user='https://github.com/pierreglaser'
cell objects are containers for the free variables of functions defined in a
local scope. They are located in a function's __closure__ attribute (when
it is not None). A cell is a very simple object, with a single (optional, e.g
the cell can be empty) attribute: cell_contents.
The C/Python API provides a constructor to create such objects (PyCell_New).
However no cell.__new__ method is exposed to the pure python user. Workarounds
exist, but are hacky, and involve the creation of intermediate, unused
functions.
Why would cell-creation be useful? because creating cells happens in pickle
extensions modules designed to save user-defined functions and classes
(https://github.com/cloudpipe/cloudpickle) (*). These moudules are dependencies of
many widely-used data science frameworks (pyspark, ray, dask). Exposing a cell
constructor will simplify theses extensions code base, and alleviate their
maintenance cost.
I propose to add and expose a simple cell constructor, that accepts 0 (empty
cells) or 1 arguments. I also propose to expose the cell type in Lib/types.py
(as types.CellType)
Activity
pierreglaser commentedon Feb 6, 2019
cell objects are containers for the free variables of functions defined in a
local scope. They are located in a function's __closure__ attribute (when
it is not None). A cell is a very simple object, with a single (optional, e.g
the cell can be empty) attribute: cell_contents.
The C/Python API provides a constructor to create such objects (PyCell_New).
However no cell.__new__ method is exposed to the pure python user. Workarounds
exist, but are hacky, and involve the creation of intermediate, unused
functions.
Why would cell-creation be useful? because creating cells happens in pickle
extensions modules designed to save user-defined functions and classes
(https://github.com/cloudpipe/cloudpickle) (*). These moudules are dependencies of
many widely-used data science frameworks (pyspark, ray, dask). Exposing a cell
constructor will simplify theses extensions code base, and alleviate their
maintenance cost.
I propose to add and expose a simple cell constructor, that accepts 0 (empty
cells) or 1 arguments. I also propose to expose the cell type in Lib/types.py
(as types.CellType)
(*): see related issues: https://bugs.python.org/issue35900
pitrou commentedon Feb 6, 2019
Hi Pierre,
You'll want to submit your patch as a GitHub pull request.
Also your PR will have to contain:
You may want to read more in the developer's guide:
https://devguide.python.org/
pitrou commentedon Feb 7, 2019
New changeset df8d2cd by Antoine Pitrou (Pierre Glaser) in branch 'master':
bpo-35911: add cell constructor (GH-11771)
df8d2cd