Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cythonize Param #923

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions param/_utils.py → param/_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def concrete_descendents(parentclass):

Only non-abstract classes will be included.
"""
return {c.__name__:c for c in descendents(parentclass)
return {c.__name__: c for c in descendents(parentclass)
if not _is_abstract(c)}

def _abbreviate_paths(pathspec,named_paths):
Expand Down Expand Up @@ -582,13 +582,6 @@ def exceptions_summarized():
print(f"{etype.__name__}: {value}", file=sys.stderr)


def _in_ipython():
try:
get_ipython()
return True
except NameError:
return False

_running_tasks = set()

def async_executor(func):
Expand Down
17 changes: 2 additions & 15 deletions param/parameterized.py → param/parameterized.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
_deprecated,
_deprecate_positional_args,
_dict_update,
_in_ipython,
_is_auto_name,
_is_mutable_container,
_recursive_repr,
Expand All @@ -57,20 +56,8 @@
descendents,
)

# Ideally setting param_pager would be in __init__.py but param_pager is
# needed on import to create the Parameterized class, so it'd need to precede
# importing parameterized.py in __init__.py which would be a little weird.
if _in_ipython():
# In case the optional ipython module is unavailable
try:
from .ipython import ParamPager, ipython_async_executor as async_executor
param_pager = ParamPager(metaclass=True) # Generates param description
except ImportError:
from ._utils import async_executor
else:
from ._utils import async_executor
param_pager = None

from ._utils import async_executor
param_pager = None

from inspect import getfullargspec

Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
requires = ["hatchling", "hatch-vcs", 'hatch-cython', 'cython']
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel.hooks.cython]
dependencies = ["hatch-cython", 'cython']

[tool.hatch.build.targets.wheel.hooks.cython.options]
includes = []
directives = { boundscheck = false, nonecheck = false, language_level = 3, binding = true }
compile_py = false

[project]
name = "param"
dynamic = ["version"]
Expand Down Expand Up @@ -92,6 +100,9 @@ Releases = "https://github.com/holoviz/param/releases"
Source = "https://github.com/holoviz/param"
HoloViz = "https://holoviz.org/"

[tool.setuptools]
packages = ["param", "numbergen"]

[tool.hatch.version]
source = "vcs"

Expand All @@ -100,8 +111,8 @@ include = [
"/param",
"/numbergen",
]

[tool.hatch.build.targets.sdist]
packages = ["param", "numbergen"]
include = [
"/param",
"/numbergen",
Expand Down