Python High Performance Programming Boost the performance of your Python programs using advanced techniques 1st Edition Gabriele Lanaro - Download the full set of chapters carefully compiled
Python High Performance Programming Boost the performance of your Python programs using advanced techniques 1st Edition Gabriele Lanaro - Download the full set of chapters carefully compiled
com
https://ebookname.com/product/python-high-performance-
programming-boost-the-performance-of-your-python-programs-
using-advanced-techniques-1st-edition-gabriele-lanaro/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookname.com/product/python-high-performance-2nd-
edition-gabriele-lanaro/
https://ebookname.com/product/fundamentals-of-python-first-
programs-1st-edition-kenneth-a-lambert/
https://ebookname.com/product/beginning-python-using-
python-2-6-and-python-3-1-wrox-programmer-to-programmer-james-
payne/
https://ebookname.com/product/religion-and-politics-in-the-
middle-east-identity-ideology-institutions-and-attitudes-second-
edition-edition-robert-d-lee/
Gilbert Law Summary on Criminal Procedure 19th ed.
Edition Paul Marcus
https://ebookname.com/product/gilbert-law-summary-on-criminal-
procedure-19th-ed-edition-paul-marcus/
Dream Lucky When FDR was in the White House Count Basie
was on the radio and everyone wore a hat 1st Edition
Roxane Orgill
https://ebookname.com/product/dream-lucky-when-fdr-was-in-the-
white-house-count-basie-was-on-the-radio-and-everyone-wore-a-
hat-1st-edition-roxane-orgill/
https://ebookname.com/product/making-sense-of-the-dollar-
exposing-dangerous-myths-about-trade-and-foreign-exchange-1st-
edition-chandler/
https://ebookname.com/product/constitutional-and-administrative-
law-helen-fenwick/
https://ebookname.com/product/the-syriac-bible-according-to-the-
mosul-edition-yusuf-dawud/
The Bible in the Syriac Tradition Third Edition
Sebastian Brock
https://ebookname.com/product/the-bible-in-the-syriac-tradition-
third-edition-sebastian-brock/
Python High Performance
Programming
Gabriele Lanaro
BIRMINGHAM - MUMBAI
Python High Performance Programming
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78328-845-8
www.packtpub.com
Reviewers Proofreader
Daniel Arbuckle Linda Morris
Mike Driscoll
Albert Lukaszewski Indexer
Rekha Nair
Acquisition Editors
Owen Roberts Production Coordinators
Pooja Chiplunkar
Harsha Bharwani
Manu Joseph
Commissioning Editor
Shaon Basu Cover Work
Pooja Chiplunkar
Technical Editors
Akashdeep Kundu
Faisal Siddiqui
About the Author
Mike Driscoll has been programming in Python since Spring 2006. He enjoys
writing about Python on his blog at http://www.blog.pythonlibrary.org/.
Mike also occasionally writes for the Python Software Foundation, i-Programmer,
and Developer Zone. He enjoys photography and reading a good book. Mike has
also been a technical reviewer for Python 3 Object Oriented Programming, Python
2.6 Graphics Cookbook, and Tkinter GUI Application Development Hotshot.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM
http://PacktLib.PacktPub.com
Why Subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print and bookmark content
• On demand and accessible via web browser
[ ii ]
Preface
Python is a programming language renowned for its simplicity, elegance, and
the support of an outstanding community. Thanks to the impressive amount
of high-quality third-party libraries, Python is used in many domains.
Python is an easier language to deal with and it can be used to quickly write
complex applications. Thanks to its tight integration with C, Python is able to
avoid the performance drop associated with dynamic languages. You can use
blazing fast C extensions for performance-critical code and retain all the
convenience of Python for the rest of your application.
In this book, you will learn, in a step-by-step method how to find and speedup
the slow parts of your programs using basic and advanced techniques.
The style of the book is practical; every concept is explained and illustrated with
examples. This book also addresses common mistakes and teaches how to avoid
them. The tools used in this book are quite popular and battle-tested; you can be
sure that they will stay relevant and well-supported in the future.
This book starts from the basics and builds on them, therefore, I suggest you
to move through the chapters in order.
Chapter 2, Fast Array Operations with NumPy is a guide to the NumPy package.
NumPy is a framework for array calculations in Python. It comes with a clean
and concise API, and efficient array operations.
The book was written and tested on Ubuntu 13.10. The examples will likely run on
Mac OS X with little or no changes.
[2]
Preface
However, the scope of this book is broad and the concepts can be applied to any
domain. Since the book addresses both basic and advanced topics, it contains
useful information for programmers with different Python proficiency levels.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"The plot function included in matplotlib can display our particles as points
on a Cartesian grid and the FuncAnimation class can animate the evolution of
our particles over time."
def visualize(simulator):
[3]
Preface
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
In [1]: import purepy
In [2]: %timeit purepy.loop()
100 loops, best of 3: 8.26 ms per loop
In [3]: %timeit purepy.comprehension()
100 loops, best of 3: 5.39 ms per loop
In [4]: %timeit purepy.generator()
100 loops, best of 3: 5.07 ms per loop
New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes, for example, appear in the text like this: "You
can navigate to the Call Graph or the Caller Map tabs by double-clicking on the
rectangles."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
[4]
Preface
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the errata submission form link,
and entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded on our website, or added to any list of
existing errata, under the Errata section of that title. Any existing errata can be viewed
by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at questions@packtpub.com if you are having a problem with
any aspect of the book, and we will do our best to address it.
[5]
Another Random Document on
Scribd Without Any Related Topics
The ancient Britons had them. That these rings were used for
money, is confirmed by the fact that, on being weighed, by far the
greater number of them appear to be exact multiples of a certain
standard unit. Layard mentions[5] that Dr. Lepsius has recently
published a bas relief, from an Egyptian tomb, representing a man
weighing rings of gold and silver, with weights in the form of a bull’s
head; and Layard also gives a seeming outline of the subject,
(although its description speaks of “weights in the form of a seated
lion.”) It is presumed that these rings are intended for ring-money;
the fact of weighing them strengthens this idea; and see Wilkinson’s
Popular Account of the Ancient Egyptians, (revised,) ii. 148-9.
§ 4. We not only find rings in the most ancient times, but we also
trace them in mythology.
Fish, in antediluvian period, were intelligent, had fine musical
perception and were even affectionate. Thus, in relation to Theseus,
the Athenian prince: Minos happened to load Theseus with
reproaches, especially on account of his birth; and told him, that, if
he were the son of Neptune, he would have no difficulty in going to
the bottom of the sea; and then threw a ring in to banter him. The
Athenian prince plunged in, and might have been food for fishes,
had they not, in the shape of dolphins, taken him upon their backs,
as they had done Arion, and conveyed him to the palace of
Amphitrite.[6] It is not said whether she, as Neptune’s wife, had a
right to the jetsam, flotsam, and lagan, to the sweepings or stray
jewelry of the ocean; but she was able to hand Theseus the ring,
and also to give him a crown, which he presented to the ill-used lady
Ariadne, and it was afterwards placed among the stars.
And, coupled with mythology, we have, according to the ancients,
the origin of the ring. Jupiter, from revenge, caused Strength, Force
and Vulcan to chain his cousin-german Prometheus to the frosty
Caucasus, where a vulture, all the livelong day, banqueted his fill on
the black viands of his hot liver. The god had sworn to keep
Prometheus there (according to Hesiod[7]) eternally; but other
authors give only thirty thousand years as the limit. He who had
punished did, for reasons, forgive; but as Jupiter had sworn to keep
Prometheus bound for the space of time mentioned, he, in order not
to violate his oath, commanded that Prometheus should always wear
upon his finger an iron ring, to or in which should be fastened a
small fragment of Caucasus, so that it might be true, in a certain
sense, that Prometheus still continued bound to that rock. Thus, as
we have said, came the idea of the first ring, and, we may add, the
insertion of a stone.[8]
While some writers, under this story, connect Prometheus with the
first ring, Pliny still says that the inventor of it is not known, and
observes that it was used by the Babylonians, Chaldeans, Persians
and Greeks, although, as he thinks, the latter were unacquainted
with it at the time of the Trojan war, as Homer does not mention it.
[9]
It has however been said that Dschemid, who made known the
solar year, introduced the use of the ring.[10]
Touching Pliny’s notion of the antiquity of rings, there is, in
Southey’s “Commonplace Book,” (second series,[11]) the following
quotation from “Treasurie of Auncient and Moderne Times,” (1619:)
“But the good olde man Plinie cannot overreach us with his idle
arguments and conjectures, for we read in Genesis that Joseph, who
lived above five hundred yeares before the warres of Troy, having
expounded the dreame of Pharaoh, king of Ægypt, was, by the
sayde prince, made superintendent over his kingdom, and for his
safer possession in that estate, he took off his ring from his hand
and put it upon Joseph’s hand.” ... “In Moses’s time, which was more
than foure hundred yeares before Troy warres, wee find rings to be
then in use; for we reade that they were comprehended in the
ornaments which Aaron the high priest should weare, and they of his
posteritie afterward, as also it was avouched by Josephus. Whereby
appeareth plainly, that the use of rings was much more ancient than
Plinie reporteth them in his conjectures: but as he was a Pagan, and
ignorant in sacred writings, so it is no marvell if these things went
beyond his knowledge.”
It is pretended that seal-rings were an invention of the
Lacedemonians, who, not content with locking their coffers, added a
seal; for which purpose they made use of worm-eaten wood, with
which they impressed wax or soft wood; and after this they learned
to engrave seals.[12]
§ 11. Rings were in use among the Gauls and Britons, but
seemingly for ornament only. They are often found in British
barrows. Anglo-Saxon rings were common.[34] William de Belmeis
gave certain lands to St. Paul’s Cathedral, and at the same time
directed that his gold ring set with a ruby should, together with the
seal, be affixed to the charter for ever. The same thing was done by
Osbart de Camera, he granting to St. Paul’s, in pure alms and for the
health of his soul, certain lands; giving possession by his gold ring,
wherein a ruby was set; and appointing that the same gold ring with
his seal should for ever be affixed to the charter whereby he
disposed of them.[35]
Anglo-Saxon kings gave rings to their wittenagemot and courtiers,
and they to their descendants.
Pliny, the Roman naturalist, gravely tells us that the oyster which
produces pearls, does so from feeding on heavenly dew. Drummond
thus translates him:
The ancient idea that pearls are generated of the dews of heaven,
is pretty conclusively met by Cardanus,[48] who says it is fabulous,
seeing that the shell fishes, in which they are conceived, have their
residence in the very bottom of the depth of the sea.
The charlatan Leoni de Spoleto prescribed the drink of dissolved
pearls for Lorenzo the Magnificent, when he was attacked by fever
aggravated by hereditary gout.[49]
There was supposed to be a gem called a carbuncle, which
emitted, not reflected, but native light.[50] Our old literature abounds
with allusions to this miraculous gem. Shakspeare has made use of it
in Titus Andronicus, where Martius goes down into a pit, and, by it,
discovers the body of Lord Bassianus; and calls up to Quintus thus:
[51]
They are both of gold, while No. 2 has a white stone which works
upon a swivel.
We add, in this portion of our book, another from
the British Museum. It is worked from Greek or
Etruscan gold, and was found in the Abruzzi.
Illustrations of some of the Egyptian seal-rings
contained in the British Museum, will be found in
Knight’s Pictorial Bible, at the end of the third chapter
of Esther.
Fashion and Fancy have given us rings of all
imaginable shapes, and these powers, joined with
Religion and Love, have traced upon them every supposable subject.
Although modern rings seldom display
the exquisite cutting and artistic taste which
appear upon antiques, still the latter exhibit
sentimental phrases and sentiments similar
to such as are observed upon rings of the
present day. The Greeks were full of
gallantry. Time has preserved to us
incontestable proofs of the vows which they
made to mistresses and friends, as well as
of the trouble they took and the expense
they went to in order to perpetuate their
sentiments. Caylus,[61] who says this, gives
a drawing of a ring bearing the words KIPIA
KAAH, Beautiful Ciria; and adds, “This
inscription is simple but energetic; it
appears to me to suit the sentiment.” In
Montfaucon are several illustrations of Greek sentences upon rings,
which carry out what Caylus has observed; thus there are (rendered
into English), Good be with you, Madam. Good be with you, Sir.
Good be with him who wears you and all his household. Remember
it. Theanus is my light. Upon a ring bearing a hand which holds a
ring: Remember good fortune. There are, also, upon Roman rings,
sentiment and compliment in Latin sentences, as thus translated:
Live happy, my hostess. You have this pledge of love. Live in God.
Live. And Caylus[62] gives a description and drawing of a remarkably
formed gold ring; and although it bears Greek words, he leaves it in
doubt whether it is of Roman or Grecian workmanship. It has the
appearance of three rings united, widened in the front and tapering
within the hand. Upon the wide part of each are two letters, the
whole forming ZHCAIC, Mayest thou live. The Romans often
preferred the Greek language in their most familiar customs.
A ring of bronze has been discovered, in the form of a snake with
its tail in its mouth, made on the principle of some of our steel rings
which we use to hold household keys, widening their circle by
pressure.[63] In the finger-ring, the part in
the mouth is inserted loose, so as to draw
out and increase to the size of the circle
needed.
Rings of gold are common in England at
the present day, made to form a strap with
buckles, precisely, in shape, a common belt
or collar. It lies flat like an ordinary leather strap, and is formed of
small pieces of gold which are kept so delicately together that the
lines of meeting are scarcely perceptible. This is accomplished by
having many minute and unseen hinges, which make the whole
pliable and allow it to be buckled (as a ring) upon the finger.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com