Skip to content

Make khash its own extension #18472

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

Merged
merged 3 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/_libs/src/khash.pxd → pandas/_libs/khash.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# cython: profile=False
from cpython cimport PyObject
from numpy cimport int64_t, uint64_t, int32_t, uint32_t, float64_t

Expand Down
5 changes: 5 additions & 0 deletions pandas/_libs/khash.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# cython: profile=False
"""
Dummy file supporting; see khash.pxd
"""
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/resolution.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ np.import_array()

from util cimport is_string_object, get_nat

from khash cimport (
from pandas._libs.khash cimport (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can do relative imports here?

from ..khash cimport ? not sure. but this is ok for now.

khiter_t,
kh_destroy_int64, kh_put_int64,
kh_init_int64, kh_int64_t,
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class CheckSDist(sdist_class):
'pandas/_libs/index.pyx',
'pandas/_libs/algos.pyx',
'pandas/_libs/join.pyx',
'pandas/_libs/khash.pyx',
'pandas/_libs/indexing.pyx',
'pandas/_libs/interval.pyx',
Copy link
Contributor

Choose a reason for hiding this comment

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

hashtable is still coupled to khash_python.h

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess I'm still unclear on the transitive-dependencies policy. A bunch of other things are coupled to hashtable, so are they also coupled to khash_python.h?

Copy link
Contributor

Choose a reason for hiding this comment

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

well this is exactly the issue
you now have an actual module rather than header only so you shouldn’t import from the c files and instead put the defa inside the .pxd

you may want to find an example how to do this
i don’t like the idea of a dummy module

Copy link
Member Author

Choose a reason for hiding this comment

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

Would getting rid of the .pyx file solve this?

'pandas/_libs/hashing.pyx',
Expand Down Expand Up @@ -514,6 +515,9 @@ def pxd(name):
'pyxfile': '_libs/join',
'pxdfiles': ['_libs/src/util', '_libs/hashtable'],
'depends': _pxi_dep['join']},
'_libs.khash': {
'pyxfile': '_libs/khash',
'depends': ['pandas/_libs/src/klib/khash_python.h']},
'_libs.lib': {
'pyxfile': '_libs/lib',
'pxdfiles': ['_libs/src/util', '_libs/missing'],
Expand Down Expand Up @@ -550,7 +554,6 @@ def pxd(name):
'_libs.tslib': {
'pyxfile': '_libs/tslib',
'pxdfiles': ['_libs/src/util',
'_libs/src/khash',
'_libs/tslibs/conversion',
'_libs/tslibs/timedeltas',
'_libs/tslibs/timestamps',
Expand Down Expand Up @@ -591,12 +594,11 @@ def pxd(name):
'sources': np_datetime_sources},
'_libs.tslibs.parsing': {
'pyxfile': '_libs/tslibs/parsing',
'pxdfiles': ['_libs/src/util',
'_libs/src/khash']},
'pxdfiles': ['_libs/src/util']},
'_libs.tslibs.resolution': {
'pyxfile': '_libs/tslibs/resolution',
'pxdfiles': ['_libs/src/util',
'_libs/src/khash',
'_libs/khash',
'_libs/tslibs/frequencies',
'_libs/tslibs/timezones'],
'depends': tseries_depends,
Expand Down