Cython: [a guide for Python programmers]
Gespeichert in:
1. Verfasser: | |
---|---|
Format: | Buch |
Sprache: | English |
Veröffentlicht: |
Beijing ; Köln [u.a.]
O'Reilly
2015
|
Ausgabe: | 1. ed. |
Schlagworte: | |
Online-Zugang: | Inhaltsverzeichnis |
Beschreibung: | XVI, 234 S. |
ISBN: | 9781491901557 |
Internformat
MARC
LEADER | 00000nam a2200000 c 4500 | ||
---|---|---|---|
001 | BV042454231 | ||
003 | DE-604 | ||
005 | 20150324 | ||
007 | t | ||
008 | 150324s2015 |||| 00||| eng d | ||
020 | |a 9781491901557 |c Pbk. : EUR 24.50 |9 978-1-491-90155-7 | ||
035 | |a (OCoLC)906810920 | ||
035 | |a (DE-599)BVBBV042454231 | ||
040 | |a DE-604 |b ger | ||
041 | 0 | |a eng | |
049 | |a DE-20 |a DE-11 |a DE-83 |a DE-523 | ||
084 | |a ST 250 |0 (DE-625)143626: |2 rvk | ||
100 | 1 | |a Smith, Kurt W. |e Verfasser |0 (DE-588)1068770104 |4 aut | |
245 | 1 | 0 | |a Cython |b [a guide for Python programmers] |c Kurt W. Smith |
250 | |a 1. ed. | ||
264 | 1 | |a Beijing ; Köln [u.a.] |b O'Reilly |c 2015 | |
300 | |a XVI, 234 S. | ||
336 | |b txt |2 rdacontent | ||
337 | |b n |2 rdamedia | ||
338 | |b nc |2 rdacarrier | ||
650 | 0 | 7 | |a C |g Programmiersprache |0 (DE-588)4113195-2 |2 gnd |9 rswk-swf |
650 | 0 | 7 | |a Python |g Programmiersprache |0 (DE-588)4434275-5 |2 gnd |9 rswk-swf |
650 | 0 | 7 | |a Programmiersprache |0 (DE-588)4047409-4 |2 gnd |9 rswk-swf |
689 | 0 | 0 | |a Programmiersprache |0 (DE-588)4047409-4 |D s |
689 | 0 | 1 | |a Python |g Programmiersprache |0 (DE-588)4434275-5 |D s |
689 | 0 | 2 | |a C |g Programmiersprache |0 (DE-588)4113195-2 |D s |
689 | 0 | |5 SWB | |
856 | 4 | 2 | |m HBZ Datenaustausch |q application/pdf |u http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=027889462&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |3 Inhaltsverzeichnis |
943 | 1 | |a oai:aleph.bib-bvb.de:BVB01-027889462 |
Datensatz im Suchindex
_version_ | 1808678800688414720 |
---|---|
adam_text |
Titel: Cython
Autor: Smith, Kurt W
Jahr: 2015
Table of Contents Preface. xi 1. Cython Essentials. 1 Comparing Python, C, and Cython 2 Function Call Overhead 5 Looping 6 Math Operations 6 Stack Versus Heap Allocation 6 Tempering Our Enthusiasm 7 Wrapping C Code with Cython 8 Summary 10 2. Compiling and Running Cython Code. 11 The Cython Compilation Pipeline 12 Installing and Testing Our Setup 13 The Standard Way: Using distutils with cythonize 14 Our distutils Script 15 Compiling with distutils on Mac OS X and Linux 15 Compiling with distutils on Windows 16 Using Our Extension Module 17 Interactive Cython with IPythons %%cython Magic 19 Compiling On-the-Fly with pyximport 21 Controlling pyximport and Managing Dependencies 22 pyximport Example with External Dependencies 23 Rolling Our Own and Compiling by Hand 24 Using Cython with Other Build Systems 26 CMake and Cython 26 SCons and Cython 26 Make and Cython 26
Compiler Directives Summary 28 29 3. Cython in Depth. 31 Interpreted Versus Compiled Execution 31 Dynamic Versus Static Typing 3 2 Static Type Declaration with cdef 34 Automatic Type Inference in Cython 36 C Pointers in Cython 37 Mixing Statically and Dynamically Typed Variables 3 9 Statically Declaring Variables with a Python Type 41 Static Typing for Speed 43 Reference Counting and Static String Types 45 Cythons Three Kinds of Functions 46 Python Functions in Cython with the def Keyword 46 C Functions in Cython with the cdef Keyword 49 Combining def and cdef Functions with cpdef 50 Functions and Exception Handling 51 Functions and the embedsignature Compiler Directive 53 Type Coercion and Casting 55 Declaring and Using structs, unions, and enums 56 Type Abasing with ctypedef 59 Cython for Loops and while Loops 61 Guidelines for Efficient Loops 61 Loop Example 62 The Cython Preprocessor 63 Bridging the Python 2 and Python 3 Divide 64 str, Unicode, bytes, and All That 66 Summary 67 4. Cython in Practice: N-Body Simulation.69 Overview of the N-Body Python Code 69 Converting to Cython 7 1 Python Data Structures and Organization 72 Converting Data Structures to structs 73 Running the Cythonized Version 75 Summary 76 5. Cython and Extension Types. 79 Comparing Python Classes and Extension Types 79 Extension Types in Cython 80 Type Attributes and Access Control 83 vi I Table of Contents
C-Level Initialization and Finalization 85 cdef and cpdef Methods 86 Inheritance and Subclassing 89 Casting and Subclasses 90 Extension Type Objects and None 91 Extension Type Properties in Cython 92 Special Methods Are Even More Special 94 Arithmetic Methods 94 Rich Comparisons 96 Iterator Support 98 Summary 99 6. Organizing Cython Code. 101 Cython Implementation (.pyx) and Declaration (.pxd) Files 102 The cimport Statement 105 Predefined Definition Files 107 Include Files and the include Statement 109 Organizing and Compiling Cython Modules Inside Python Packages 110 Summary 113 7. Wrapping C Libraries with Cython.115 Declaring External C Code in Cython 115 Cython Does Not Automate Wrapping 117 Declaring External C Functions and typedefs 118 Declaring and Wrapping C structs, unions, and enums 119 Wrapping C Functions 121 Wrapping C structs with Extension Types 122 Constants, Other Modifiers, and Controlling What Cython Generates 125 Error Checking and Raising Exceptions 128 Callbacks 128 Callbacks and Exception Propagation 133 Summary 134 8. Wrapping C++Libraries with Cython. 135 Simple Example: MT_RNG Class 135 The Wrapper Extension Type 137 Compiling with C++ 138 Using Our Wrapper from Python 139 Overloaded Methods and Functions 140 Operator Overloading 142 C++ Exceptions 144 Stack and Heap Allocation of C++ Instances 145 Table of Contents | vii
Working with C++ Class Hierarchies C++ Templates Templated Functions and Cython’s Fused Types Templated Classes Iterators and Nested Classes Included STL Container Class Declarations Memory Management and Smart Pointers Summary 9. Cython Profiling Tools. Cython Runtime Profiling Performance Profiling and Annotations Summary 10. Cython, NumPy, and Typed Memoryviews. The Power of the New Buffer Protocol The memoryview Type Typed Memoryviews Typed Memoryview Example C-Level Access to Typed Memoryview Data Trading Safety for Performance Declaring Typed Memoryviews Using Typed Memoryviews Beyond Buffers Wrapping C and C++ Arrays Correct (and Automatic) Memory Management with Cython and C Arrays Summary 11. Cython in Practice: Spectral Norm. Overview of the Spectral Norm Python Code Performance Profiling Cythonizing Our Code Adding Static Type Information Using Typed Memoryviews Comparing to the C Implementation Summary 12. Parallel Programming with Cython. Thread-Based Parallelism and the Global Interpreter Lock The nogil Function Attribute The with nogil Context Manager Using prange to Parallelize Loops 146 147 148 149 150 151 154 157 159 159 164 170 171 172 173 176 176 177 178 179 183 187 189 189 192 193 193 196 197 198 198 200 200 201 201 202 203 204 viii | Table of Contents
Using prange 208 prange Options 209 Using prange for Reductions 210 Parallel Programming Pointers and Pitfalls 212 Summary 213 13. Cython in Context. 215 Cython Versus Project X 215 Other Ahead-of-Time Compilers for Python 216 Python Wrapper Projects 217 Just-in-Time Compilers for Python 218 Summary 219 Index. 221 Table of Contents | ix |
any_adam_object | 1 |
author | Smith, Kurt W. |
author_GND | (DE-588)1068770104 |
author_facet | Smith, Kurt W. |
author_role | aut |
author_sort | Smith, Kurt W. |
author_variant | k w s kw kws |
building | Verbundindex |
bvnumber | BV042454231 |
classification_rvk | ST 250 |
ctrlnum | (OCoLC)906810920 (DE-599)BVBBV042454231 |
discipline | Informatik |
edition | 1. ed. |
format | Book |
fullrecord | <?xml version="1.0" encoding="UTF-8"?><collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>00000nam a2200000 c 4500</leader><controlfield tag="001">BV042454231</controlfield><controlfield tag="003">DE-604</controlfield><controlfield tag="005">20150324</controlfield><controlfield tag="007">t</controlfield><controlfield tag="008">150324s2015 |||| 00||| eng d</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9781491901557</subfield><subfield code="c">Pbk. : EUR 24.50</subfield><subfield code="9">978-1-491-90155-7</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(OCoLC)906810920</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DE-599)BVBBV042454231</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">DE-604</subfield><subfield code="b">ger</subfield></datafield><datafield tag="041" ind1="0" ind2=" "><subfield code="a">eng</subfield></datafield><datafield tag="049" ind1=" " ind2=" "><subfield code="a">DE-20</subfield><subfield code="a">DE-11</subfield><subfield code="a">DE-83</subfield><subfield code="a">DE-523</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">ST 250</subfield><subfield code="0">(DE-625)143626:</subfield><subfield code="2">rvk</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Smith, Kurt W.</subfield><subfield code="e">Verfasser</subfield><subfield code="0">(DE-588)1068770104</subfield><subfield code="4">aut</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Cython</subfield><subfield code="b">[a guide for Python programmers]</subfield><subfield code="c">Kurt W. Smith</subfield></datafield><datafield tag="250" ind1=" " ind2=" "><subfield code="a">1. ed.</subfield></datafield><datafield tag="264" ind1=" " ind2="1"><subfield code="a">Beijing ; Köln [u.a.]</subfield><subfield code="b">O'Reilly</subfield><subfield code="c">2015</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">XVI, 234 S.</subfield></datafield><datafield tag="336" ind1=" " ind2=" "><subfield code="b">txt</subfield><subfield code="2">rdacontent</subfield></datafield><datafield tag="337" ind1=" " ind2=" "><subfield code="b">n</subfield><subfield code="2">rdamedia</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="b">nc</subfield><subfield code="2">rdacarrier</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">C</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4113195-2</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Python</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4434275-5</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Programmiersprache</subfield><subfield code="0">(DE-588)4047409-4</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="689" ind1="0" ind2="0"><subfield code="a">Programmiersprache</subfield><subfield code="0">(DE-588)4047409-4</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2="1"><subfield code="a">Python</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4434275-5</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2="2"><subfield code="a">C</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4113195-2</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2=" "><subfield code="5">SWB</subfield></datafield><datafield tag="856" ind1="4" ind2="2"><subfield code="m">HBZ Datenaustausch</subfield><subfield code="q">application/pdf</subfield><subfield code="u">http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=027889462&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA</subfield><subfield code="3">Inhaltsverzeichnis</subfield></datafield><datafield tag="943" ind1="1" ind2=" "><subfield code="a">oai:aleph.bib-bvb.de:BVB01-027889462</subfield></datafield></record></collection> |
id | DE-604.BV042454231 |
illustrated | Not Illustrated |
indexdate | 2024-08-29T00:15:18Z |
institution | BVB |
isbn | 9781491901557 |
language | English |
oai_aleph_id | oai:aleph.bib-bvb.de:BVB01-027889462 |
oclc_num | 906810920 |
open_access_boolean | |
owner | DE-20 DE-11 DE-83 DE-523 |
owner_facet | DE-20 DE-11 DE-83 DE-523 |
physical | XVI, 234 S. |
publishDate | 2015 |
publishDateSearch | 2015 |
publishDateSort | 2015 |
publisher | O'Reilly |
record_format | marc |
spelling | Smith, Kurt W. Verfasser (DE-588)1068770104 aut Cython [a guide for Python programmers] Kurt W. Smith 1. ed. Beijing ; Köln [u.a.] O'Reilly 2015 XVI, 234 S. txt rdacontent n rdamedia nc rdacarrier C Programmiersprache (DE-588)4113195-2 gnd rswk-swf Python Programmiersprache (DE-588)4434275-5 gnd rswk-swf Programmiersprache (DE-588)4047409-4 gnd rswk-swf Programmiersprache (DE-588)4047409-4 s Python Programmiersprache (DE-588)4434275-5 s C Programmiersprache (DE-588)4113195-2 s SWB HBZ Datenaustausch application/pdf http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=027889462&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA Inhaltsverzeichnis |
spellingShingle | Smith, Kurt W. Cython [a guide for Python programmers] C Programmiersprache (DE-588)4113195-2 gnd Python Programmiersprache (DE-588)4434275-5 gnd Programmiersprache (DE-588)4047409-4 gnd |
subject_GND | (DE-588)4113195-2 (DE-588)4434275-5 (DE-588)4047409-4 |
title | Cython [a guide for Python programmers] |
title_auth | Cython [a guide for Python programmers] |
title_exact_search | Cython [a guide for Python programmers] |
title_full | Cython [a guide for Python programmers] Kurt W. Smith |
title_fullStr | Cython [a guide for Python programmers] Kurt W. Smith |
title_full_unstemmed | Cython [a guide for Python programmers] Kurt W. Smith |
title_short | Cython |
title_sort | cython a guide for python programmers |
title_sub | [a guide for Python programmers] |
topic | C Programmiersprache (DE-588)4113195-2 gnd Python Programmiersprache (DE-588)4434275-5 gnd Programmiersprache (DE-588)4047409-4 gnd |
topic_facet | C Programmiersprache Python Programmiersprache Programmiersprache |
url | http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=027889462&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |
work_keys_str_mv | AT smithkurtw cythonaguideforpythonprogrammers |