Skip to content

Commit c35773a

Browse files
authored
Merge pull request #733 from izaid/various
Made registry loading happening in dynd rather than dynd.nd
2 parents ddd43f5 + 792b47d commit c35773a

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

dynd/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919
'__libdynd_version__', '__version__', '__libdynd_git_sha1__', '__git_sha1__',
2020
'annotate', 'test', 'load'
2121
]
22+
23+
from .nd.registry import propagate_all
24+
25+
propagate_all()

dynd/nd/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
inf = float('inf')
1616
nan = float('nan')
1717

18-
from .registry import publish_callables
1918
from . import functional
20-
21-
publish_callables()

dynd/nd/registry.pxd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
from libcpp.map cimport map
2+
from libcpp.pair cimport pair
3+
from libcpp.string cimport string
14

5+
from ..cpp.callable cimport callable
26
from ..cpp.registry cimport registered, registry_entry
37

4-
cdef extern _publish_callables(registry_entry &entry)
8+
cdef extern void propagate(registry_entry *entry)

dynd/nd/registry.pyx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,36 @@ import sys
55

66
from cython.operator cimport dereference
77

8-
from ..cpp.callable cimport callable, registered, registry_entry
9-
from ..cpp.registry cimport registered, registry_entry
10-
from ..cpp.config cimport load
11-
128
from ..config cimport translate_exception
139
from .callable cimport wrap
1410
from .array cimport _registry_assign_init as assign_init
1511

1612
assign_init()
1713

18-
from libcpp.map cimport map
19-
from libcpp.pair cimport pair
20-
from libcpp.string cimport string
21-
2214
from cython.operator import preincrement
2315

24-
cdef void add_one(registry_entry *parent_entry, const char *name, registry_entry *entry) with gil:
16+
cdef void update(registry_entry *parent_entry, const char *name, registry_entry *entry) with gil:
2517
if (entry.is_namespace()):
2618
try:
2719
new_mod = sys.modules[entry.path()]
2820
except KeyError:
2921
new_mod = imp.new_module(entry.path())
3022
sys.modules[entry.path()] = new_mod
31-
_publish_callables(dereference(entry))
23+
propagate(entry)
3224
if (not parent_entry.path().empty()):
3325
mod = sys.modules[parent_entry.path()]
3426
setattr(mod, name, new_mod)
3527
else:
3628
mod = sys.modules[parent_entry.path()]
3729
setattr(mod, name, wrap(entry.value()))
3830

39-
cdef _publish_callables(registry_entry &entry):
40-
entry.observe(&add_one)
31+
cdef void propagate(registry_entry *entry):
32+
entry.observe(update)
4133

4234
cdef map[string, registry_entry].iterator it = entry.begin()
4335
while (it != entry.end()):
44-
add_one(&entry, dereference(it).first.c_str(), &dereference(it).second)
36+
update(entry, dereference(it).first.c_str(), &dereference(it).second)
4537
preincrement(it)
4638

47-
def publish_callables():
48-
return _publish_callables(registered())
39+
def propagate_all():
40+
return propagate(&registered())

0 commit comments

Comments
 (0)