From 37d2c0d3749461ef86b0886f27128a88ddcc2f86 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 4 Apr 2016 18:33:04 -0400 Subject: Revert "pyrecwrap: skip some wrapping as an optimization" Wasn't worth the complexity; hard to get unittest to work because results (eg, for "path") were being cached. --- src/pyrecwrap.jl | 8 ++------ test/test_pyrecwrap.jl | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/pyrecwrap.jl b/src/pyrecwrap.jl index d2c2b9f..9cfc5e4 100644 --- a/src/pyrecwrap.jl +++ b/src/pyrecwrap.jl @@ -11,11 +11,8 @@ # PyCall. _pyrecwrap_cache = Dict{PyObject,Module}() -_pyx_module_skiplist = Set{ASCIIString}(["math", "os", "sys", "ast", "bytearray", "random", "errno", - "shutil", "zlib", "copy", "base64", "array", "importlib", "glob", "email", "xml", - "binascii", "encodings", "io", "tarfile", "threading", "itertools", "logging", "collections"]) -function pyrecwrap(o::PyObject, mname::Symbol=:__anon__; skiplist=_pyx_module_skiplist) +function pyrecwrap(o::PyObject, mname::Symbol=:__anon__) members = convert(Vector{Tuple{AbstractString,PyObject}}, pycall(PyCall.inspect["getmembers"], PyObject, o)) if PyCall.pyversion >= v"3" @@ -28,7 +25,6 @@ function pyrecwrap(o::PyObject, mname::Symbol=:__anon__; skiplist=_pyx_module_sk filter!(m -> !(m[1] == PyCall.inspect), members) end filter!(m -> !(m[1] in PyCall.reserved), members) - filter!(m -> !(m[1] in skiplist), members) m = Module(mname, false) # Preload module cache with this (so far empty) module _pyrecwrap_cache[o] = m @@ -41,7 +37,7 @@ function pyrecwrap(o::PyObject, mname::Symbol=:__anon__; skiplist=_pyx_module_sk end # Before recursing, check if we've seen this python module before if !haskey(_pyrecwrap_cache, mo) - _pyrecwrap_cache[mo] = pyrecwrap(mo, skiplist=skiplist) + _pyrecwrap_cache[mo] = pyrecwrap(mo) end mm = _pyrecwrap_cache[mo] push!(consts, Expr(:const, Expr(:(=), symbol(ms), mm))) diff --git a/test/test_pyrecwrap.jl b/test/test_pyrecwrap.jl index 6182779..cef3f08 100644 --- a/test/test_pyrecwrap.jl +++ b/test/test_pyrecwrap.jl @@ -1,4 +1,4 @@ -os_test = PyX.pyrecwrap(pyimport("os"), skiplist=["asdf"]) +os_test = PyX.pyrecwrap(pyimport("os")) @test os_test.path.genericpath.os.path.genericpath.os.path.genericpath != nothing -- cgit v1.2.3