docs: python bindings
* Updated the Cython example code slightly, along with the corresponding explanation.
This commit is contained in:
parent
f4d83800d8
commit
362caaf02f
@ -2122,6 +2122,7 @@ pubnum = len(publist)
|
|||||||
print("""
|
print("""
|
||||||
Number of secret keys: @{0@}
|
Number of secret keys: @{0@}
|
||||||
Number of public keys: @{1@}
|
Number of public keys: @{1@}
|
||||||
|
|
||||||
""".format(secnum, pubnum))
|
""".format(secnum, pubnum))
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@ -2172,7 +2173,10 @@ On the other hand it ran in nearly half the time; taking 6 minutes and
|
|||||||
which the CPython script alone took.
|
which the CPython script alone took.
|
||||||
|
|
||||||
The @samp{keycount.pyx} and @samp{setup.py} files used to generate this example
|
The @samp{keycount.pyx} and @samp{setup.py} files used to generate this example
|
||||||
have been added to the @samp{examples/howto/advanced/cython/} directory.
|
have been added to the @samp{examples/howto/advanced/cython/} directory
|
||||||
|
The example versions include some additional options to annotate the
|
||||||
|
existing code and to detect Cython's use. The latter comes from the
|
||||||
|
@uref{http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd, Magic Attributes} section of the Cython documentation.
|
||||||
|
|
||||||
@node Miscellaneous work-arounds
|
@node Miscellaneous work-arounds
|
||||||
@chapter Miscellaneous work-arounds
|
@chapter Miscellaneous work-arounds
|
||||||
|
@ -2027,6 +2027,7 @@ pubnum = len(publist)
|
|||||||
print("""
|
print("""
|
||||||
Number of secret keys: {0}
|
Number of secret keys: {0}
|
||||||
Number of public keys: {1}
|
Number of public keys: {1}
|
||||||
|
|
||||||
""".format(secnum, pubnum))
|
""".format(secnum, pubnum))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
@ -2077,7 +2078,10 @@ On the other hand it ran in nearly half the time; taking 6 minutes and
|
|||||||
which the CPython script alone took.
|
which the CPython script alone took.
|
||||||
|
|
||||||
The =keycount.pyx= and =setup.py= files used to generate this example
|
The =keycount.pyx= and =setup.py= files used to generate this example
|
||||||
have been added to the =examples/howto/advanced/cython/= directory.
|
have been added to the =examples/howto/advanced/cython/= directory
|
||||||
|
The example versions include some additional options to annotate the
|
||||||
|
existing code and to detect Cython's use. The latter comes from the
|
||||||
|
[[http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd][Magic Attributes]] section of the Cython documentation.
|
||||||
|
|
||||||
|
|
||||||
* Miscellaneous work-arounds
|
* Miscellaneous work-arounds
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import cython
|
||||||
import gpg
|
import gpg
|
||||||
|
|
||||||
c = gpg.Context()
|
c = gpg.Context()
|
||||||
@ -10,7 +13,14 @@ secnum = len(seclist)
|
|||||||
publist = list(pubkeys)
|
publist = list(pubkeys)
|
||||||
pubnum = len(publist)
|
pubnum = len(publist)
|
||||||
|
|
||||||
|
if cython.compiled is True:
|
||||||
|
cc = "Powered by Cython compiled C code."
|
||||||
|
else:
|
||||||
|
cc = "Powered by Python."
|
||||||
|
|
||||||
print("""
|
print("""
|
||||||
Number of secret keys: {0}
|
Number of secret keys: {0}
|
||||||
Number of public keys: {1}
|
Number of public keys: {1}
|
||||||
""".format(secnum, pubnum))
|
|
||||||
|
{2}
|
||||||
|
""".format(secnum, pubnum, cc))
|
||||||
|
@ -2,5 +2,5 @@ from distutils.core import setup
|
|||||||
from Cython.Build import cythonize
|
from Cython.Build import cythonize
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
ext_modules = cythonize("keycount.pyx")
|
ext_modules = cythonize("keycount.pyx", annotate=True)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user