aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-01-11 19:18:07 -0800
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-01-11 19:18:07 -0800
commit089a860f2d3f0ac923fc3f78190055990a940e2a (patch)
treeabb4d612166273b39aad4d204a554f27f5da486d
parentfa4700006ea1eb45387f2f4f0493ad07f78d1ad9 (diff)
parent8d0434332075768668331abd568ad5a69bb81df4 (diff)
downloadcryptography-089a860f2d3f0ac923fc3f78190055990a940e2a.tar.gz
cryptography-089a860f2d3f0ac923fc3f78190055990a940e2a.tar.bz2
cryptography-089a860f2d3f0ac923fc3f78190055990a940e2a.zip
Merge pull request #464 from exarkun/faster-cffi-usage
Make just one call to ffi.cdef for most of the definitions
-rw-r--r--cryptography/hazmat/bindings/utils.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/cryptography/hazmat/bindings/utils.py b/cryptography/hazmat/bindings/utils.py
index 69290eb3..9cc05506 100644
--- a/cryptography/hazmat/bindings/utils.py
+++ b/cryptography/hazmat/bindings/utils.py
@@ -34,6 +34,7 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
condition.
"""
ffi = cffi.FFI()
+ types = []
includes = []
functions = []
macros = []
@@ -43,8 +44,7 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
__import__(module_name)
module = sys.modules[module_name]
- ffi.cdef(module.TYPES)
-
+ types.append(module.TYPES)
macros.append(module.MACROS)
functions.append(module.FUNCTIONS)
includes.append(module.INCLUDES)
@@ -53,10 +53,7 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
# loop over the functions & macros after declaring all the types
# so we can set interdependent types in different files and still
# have them all defined before we parse the funcs & macros
- for func in functions:
- ffi.cdef(func)
- for macro in macros:
- ffi.cdef(macro)
+ ffi.cdef("\n".join(types + functions + macros))
# We include functions here so that if we got any of their definitions
# wrong, the underlying C compiler will explode. In C you are allowed