0% found this document useful (0 votes)
1 views

Python High Performance Programming 1st Edition Gabriele Lanaro instant download

The document discusses the book 'Python High Performance Programming' by Gabriele Lanaro, which focuses on optimizing Python code for better performance. It covers various topics including benchmarking, profiling, fast array operations with NumPy, C performance with Cython, and parallel processing. The book aims to provide practical techniques and tools for improving the efficiency of Python applications.

Uploaded by

celminmahamo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Python High Performance Programming 1st Edition Gabriele Lanaro instant download

The document discusses the book 'Python High Performance Programming' by Gabriele Lanaro, which focuses on optimizing Python code for better performance. It covers various topics including benchmarking, profiling, fast array operations with NumPy, C performance with Cython, and parallel processing. The book aims to provide practical techniques and tools for improving the efficiency of Python applications.

Uploaded by

celminmahamo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Python High Performance Programming 1st Edition

Gabriele Lanaro download

https://ebookbell.com/product/python-high-performance-
programming-1st-edition-gabriele-lanaro-43140680

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Parallel And High Performance Programming With Python Unlock Parallel


And Concurrent Programming In Python Fabio Nelli

https://ebookbell.com/product/parallel-and-high-performance-
programming-with-python-unlock-parallel-and-concurrent-programming-in-
python-fabio-nelli-48654648

Parallel And High Performance Programming With Python 1st Edition


Fabio Nelli

https://ebookbell.com/product/parallel-and-high-performance-
programming-with-python-1st-edition-fabio-nelli-230355662

Advanced Python Programming Build High Performance Concurrent And


Multithreaded Apps With Python Using Proven Design Patterns Dr
Gabriele Lanaro

https://ebookbell.com/product/advanced-python-programming-build-high-
performance-concurrent-and-multithreaded-apps-with-python-using-
proven-design-patterns-dr-gabriele-lanaro-22045786

High Performance Python Practical Performant Programming For Humans


2nd Edition Micha Gorelick

https://ebookbell.com/product/high-performance-python-practical-
performant-programming-for-humans-2nd-edition-micha-gorelick-24064792
High Performance Python Practical Performant Programming For Humans
Micha Gorelick

https://ebookbell.com/product/high-performance-python-practical-
performant-programming-for-humans-micha-gorelick-4766942

Handson Gpu Programming With Python And Cuda Explore Highperformance


Parallel Computing With Cuda Dr Brian Tuomanen

https://ebookbell.com/product/handson-gpu-programming-with-python-and-
cuda-explore-highperformance-parallel-computing-with-cuda-dr-brian-
tuomanen-10004658

Python High Performance 2nd Edition Gabriele Lanaro

https://ebookbell.com/product/python-high-performance-2nd-edition-
gabriele-lanaro-49052724

Python High Performance 2nd Edition Gabriele Lanaro

https://ebookbell.com/product/python-high-performance-2nd-edition-
gabriele-lanaro-10817444

Python High Performance Second Edition 2nd Edition Gabriele Lanaro

https://ebookbell.com/product/python-high-performance-second-
edition-2nd-edition-gabriele-lanaro-231197896
Table of Contents
Python High Performance Programming
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Benchmarking and Profiling
Designing your application
Writing tests and benchmarks
Timing your benchmark
Finding bottlenecks with cProfile
Profile line by line with line_profiler
Optimizing our code
The dis module
Profiling memory usage with memory_profiler
Performance tuning tips for pure Python code
Summary
2. Fast Array Operations with NumPy
Getting started with NumPy
Creating arrays
Accessing arrays
Broadcasting
Mathematical operations
Calculating the Norm
Rewriting the particle simulator in NumPy
Reaching optimal performance with numexpr
Summary
3. C Performance with Cython
Compiling Cython extensions
Adding static types
Variables
Functions
Classes
Sharing declarations
Working with arrays
C arrays and pointers
NumPy arrays
Typed memoryviews
Particle simulator in Cython
Profiling Cython
Summary
4. Parallel Processing
Introduction to parallel programming
The multiprocessing module
The Process and Pool classes
Monte Carlo approximation of pi
Synchronization and locks
IPython parallel
Direct interface
Task-based interface
Parallel Cython with OpenMP
Summary
Index
Python High Performance
Programming
Python High Performance
Programming
Copyright © 2013 Packt Publishing

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.

First published: December 2013

Production Reference: 1171213

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78328-845-8
www.packtpub.com

Cover Image by Gagandeep Sharma (<er.gagansharma@gmail.com>)


Credits
Author

Gabriele Lanaro

Reviewers

Daniel Arbuckle

Mike Driscoll

Albert Lukaszewski

Acquisition Editors

Owen Roberts

Harsha Bharwani

Commissioning Editor

Shaon Basu

Technical Editors

Akashdeep Kundu

Faisal Siddiqui

Project Coordinator

Sherin Padayatty

Proofreader

Linda Morris
Indexer

Rekha Nair

Production Coordinators

Pooja Chiplunkar

Manu Joseph

Cover Work

Pooja Chiplunkar
About the Author
Gabriele Lanaro is a PhD student in Chemistry at the University of
British Columbia, in the field of Molecular Simulation. He writes high
performance Python code to analyze chemical systems in large-
scale simulations. He is the creator of Chemlab—a high performance
visualization software in Python—and emacs-for-python—a
collection of emacs extensions that facilitate working with Python
code in the emacs text editor. This book builds on his experience in
writing scientific Python code for his research and personal projects.

I want to thank my parents for their huge, unconditional love and


support. My gratitude cannot be expressed by words but I hope
that I made them proud of me with this project.

I would also thank the Python community for producing and


maintaining a massive quantity of high-quality resources made
available for free. Their extraordinary supportive and
compassionate attitude really fed my passion for this amazing
technology.

A special thanks goes to Hessam Mehr for reviewing my drafts,


testing the code and providing extremely valuable feedback. I
would also like to thank my roommate Kaveh for being such an
awesome friend and Na for bringing me chocolate bars during
rough times.
About the Reviewers
Dr. Daniel Arbuckle is a published researcher in the fields of
robotics and nanotechnology, as well as a professional Python
programmer. He is the author of Python Testing: Beginner's Guide
from Packt Publishing and one of the authors of Morphogenetic
Engineering from Springer-Verlag.

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.

I would like to thank my beautiful wife, Evangeline, for always


supporting me. I would also like to thank friends and family for all
that they do to help me. And I would like to thank Jesus Christ for
saving me.

Albert Lukaszewski is a software consultant and the author of


MySQL for Python. He has programmed computers for nearly 30
years. He specializes in high-performance Python implementations
of network and database services. He has designed and developed
Python solutions for a wide array of industries including media,
mobile, publishing, and cinema. He lives with his family in southeast
Scotland.
www.PacktPub.com
Support files, eBooks, discount
offers and more
You might want to visit www.PacktPub.com for support files and
downloads related to your book.

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.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is


Packt's online digital book library. Here, you can access, read and
search across Packt's entire library of books.

Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser

Free Access for Packt account


holders
If you have an account with Packt at www.PacktPub.com, you can
use this to access PacktLib today and view nine entirely free books.
Simply use your login credentials for immediate access.
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.

Low-level languages such as C, C++, and Fortran are usually


preferred in performance-critical applications. Programs written in
those languages perform extremely well, but are hard to write and
maintain.

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.

And don't forget to have fun!


What this book covers
Chapter 1, Benchmarking and Profiling shows you how to find the
parts of your program that need optimization. We will use tools for
different use cases and explain how to analyze and interpret profiling
statistics.

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.

Chapter 3, C Performance with Cython is a tutorial on Cython: a


language that acts as a bridge between Python and C. Cython can
be used to write code using a superset of the Python syntax and to
compile it to obtain efficient C extensions.

Chapter 4, Parallel Processing is an introduction to parallel


programming. In this chapter, you will learn how parallel
programming is different from serial programming and how to
parallelize simple problems. We will also explain how to use
multiprocessing, IPython.parallel and cython.parallel to write
code for multiple cores.
What you need for this book
This book requires a Python installation. The examples work for both
Python 2.7 and Python 3.3 unless indicated otherwise.

In this book, we will make use of some popular Python packages:

NumPy (Version 1.7.1 or later): This package is downloadable


from the official website
(http://www.scipy.org/scipylib/download.html) and available in
most of the Linux distributions
Cython (Version 0.19.1 or later): Installation instructions are
present in the official website
(http://docs.cython.org/src/quickstart/install.html); notice that you
also need a C compiler, such as GCC (GNU Compiler
Collection), to compile your C extensions
IPython (Version 0.13.2 or later): Installation instructions are
present in the official website (http://ipython.org/install.html)

The book was written and tested on Ubuntu 13.10. The examples
will likely run on Mac OS X with little or no changes.

My suggestion for Windows users is to install the Anaconda Python


distribution (https://store.continuum.io/cshop/anaconda/), which
comes with a complete environment suitable for scientific
programming.

A convenient alternative is to use the free service wakari.io: a cloud-


based Linux and Python environment that includes the required
packages with their tools and utilities. No setup is required.

In Chapter 1, Benchmarking and Profiling, we will use KCachegrind


(http://sourceforge.net/projects/kcachegrind/), which is available for
Linux. KCachegrind has also a port for Windows—QcacheGrind—
which is also installable from source on Mac OS X.
Another Random Document on
Scribd Without Any Related Topics
“Can’t say, I’m sure,” said the boy. “The boat may have
capsized: the sea’s awfully rough now.”

“Do you mean that Mavis may be drowned or drowning?”


screamed Ruby. She had to scream, even had she been less
terribly excited, for the roar of wind was on them again, and
her voice was scarcely audible.

“I don’t see that she need be drowned,” said Bertrand. “It’s


shallow. She may have crept on shore, and be lying
somewhere among those big stones; and if not, can’t your
precious wizard friends look after her? She’s fond enough of
them.”

He was partly in earnest; but Ruby took it all as cruel


heartless mocking. She turned upon him furiously.

“You’re a brutal wicked boy,” she screamed. “I wish you


were drowned; I wish you had never come near us; I wish
—” she stopped, choked by her fury and misery, and by the
wind which came tearing round again.

Bertrand came close to her.

“As you’re so busy wishing,” he called into her ear, “you’d


better wish you hadn’t done what you have done yourself. It
was all you who started the plan, and settled how we were
to trick Winfried into the turret-room; you know you did.”

“And did I plan to drown Mavis, my own darling little


sister?” returned Ruby as well as she could speak between
her sobs and breathlessness. “Come down to the shore with
me this moment and help me to look for her, if you’re not
altogether a cruel heartless bully.”

“Not I,” said Bertrand, “we’d probably get drowned


ourselves. Just see how the waves come leaping in; they
look as if they were alive. I believe it’s all witches’ work
together. I’m not going to trust myself down there. Come
and show me the grottoes and the caves, Ruby. We may as
well shelter in them till the wind goes down a bit. We can’t
do Mavis any good; if she’s on the shore she can take care
of herself, and if she’s under the water we can’t reach her;”
and he caught hold of Ruby to pull her along, but she tore
herself from his grasp with a wrench.

“You wicked, you heartless, brutal boy,” she cried.

“I don’t care if I am drowned; I would rather be drowned


with Mavis than stay alive with you.”

And almost before Bertrand knew what she was doing, Ruby
was rushing through the little garden at the back of the
cottage on her way to descend the rough path to the shore.

He stood looking after her coolly for a moment or two with


his hands in his pockets. He tried to whistle, but it was not
very successful; the wind had the best of it.

“I don’t believe Mavis has come to any harm,” he said


aloud, though speaking to himself, and almost as if trying to
excuse his own conduct. “Anyway, I don’t see that it’s my
business to look after her, it was all her own obstinacy.”

He kicked roughly at the pebbles at his feet, and as he did


so, his glance fell on a tiny speck of colour just where he
was kicking. It was one of the blue flowers Ruby had found
in the cottage. Bertrand stooped and picked it up, and,
strange to say, he handled it gently. But as he looked at it
there came again to him the queer smarting pain in his eyes
which he had complained of in the turret-room, and
glancing up he became aware that the wind had suddenly
gone down, everything had become almost unnaturally still,
while a thin bluish haze seemed gathering closely round
where he stood. Bertrand rubbed his eyes.

“There can’t be smoke here,” he said. “What can be the


matter with my eyes?” and he rubbed them impatiently. It
did no good.

“No, that will do no good,” said a voice. It seemed quite


near him.

“Look up;” and in spite of himself the boy could not help
looking up.

“Oh,” he screamed; “oh, what is it? what is it?”

For an agony, short but indescribable, had darted through


his eyeballs, piercing, it seemed to him, to his very brain;
and Bertrand was not in some ways a cowardly boy.

There was silence, perfect, dead silence, and gradually the


intense aching, which the short terrible pain had left, began
to subside. As it did so, and Bertrand ventured to look up
again, he saw that—what he had seen, he could not
describe it better—was gone, the haze had disappeared, the
air was again clear, but far from still, for round the corner of
the old cottage the blast now came rushing and tearing, as
if infuriated at having been for a moment obliged to keep
back; and with it now came the rain, such rain as the
inland-bred boy had never seen before—blinding,
drenching, lashing rain, whose drops seemed to cut and
sting, with such force did they fall. It added to his confusion
and bewilderment. Like a hunted animal he turned and ran,
anywhere to get shelter; and soon he found himself behind
the house, and then the thought of the grottoes the little
girls had told him of returned to his mind.
“I won’t go back into that witches’ hole,” he said to himself
as he glanced back at the house. “I’ll shelter in one of the
grottoes.”

As he thought this he caught sight of an opening in the


rockery before him. It was the entrance to the very cave
where Mavis had been left by Ruby. Bertrand ran in; what
happened to him there you shall hear in good time.
Chapter Ten.
“Forget-Me-Not Land.”

“A world...
Where the month is always June.”

Three Worlds.

Ruby meanwhile was running or rather stumbling down the


stones. She cried and sobbed as she went; her pretty face
had never, I think, looked so woebegone and forlorn; for it
was new to her to be really distressed or anxious about
anything.

“Mavis, Mavis,” she called out every now and then, “are you
there darling? can’t you answer?” as if, even had the wind
been less wildly raging, Mavis could possibly have heard her
so far-off.

And before long Ruby was obliged to stop for a moment to


gather strength and breath. The wind seemed to increase
every minute. She turned her back to it for a second; the
relief was immense; and just then she noticed that she was
still clutching the little bunch of flowers she had picked up.
They made her begin to cry again.

“Mavis loves them so,” she thought, and her memory went
back to the happy peaceful afternoon they had spent with
old Adam and his grandson. How kind they were, and how
nice the cakes were that Winfried had made for them
himself!

“Oh,” thought Ruby, “I wish Bertrand had never come! It’s


all—” but there she hesitated. There had been truth in her
cousin’s mean reproach, that the mischief and the cruel
tricks they had planned had been first thought of by her.
And Ruby knew, too, in her heart, that she had not been
gentle or unselfish or kind long before she had ever seen
Bertrand. She had not been so actively naughty because
she had had no chance of being so, as it were. The coming
together of the two selfish unfeeling natures had been like
the meeting of the flint and steel, setting loose the hidden
fire.

And besides this, for Bertrand there might have been some
excuse; he had been neglected and yet spoilt; he had never
known what it was truly to love any one, whereas Ruby had
lived in love all her life; and this was her return for it.
“I have killed my little Mavis,” she sobbed. “Yes, it has been
all me. We needn’t have minded Bertrand; he couldn’t have
made me naughty if I hadn’t let him. Oh, Mavis, Mavis,
whatever shall I do?” Her glance fell again on the flowers in
her hand. They were not the least withered or spoilt, but as
fresh as if just newly gathered. They seemed to smile up at
her, and she felt somehow comforted.

“Dear little flowers,” she said. Seldom in her life had Ruby
spoken so tenderly. She started, as close beside her she
heard a faint sigh.

“Ruby,” said a voice, “can you hear me?”

“Yes,” said the little girl, beginning to tremble.

“But you cannot see me? and yet I am here, close to you,
as I have often been before. Try Ruby, try to see me.”

“Are—are you a mermaid, or a—that other thing?” asked


the child.

There came a little laugh, scarcely a laugh, then the sigh


again.

“If you could see me you would know how foolish you are,”
said the voice. “But I must have patience—it will come—
your eyes are not strong, Ruby; they are not even as strong
as Bertrand’s.”

“Yes, they are,” said Ruby indignantly. “I’ve never had sore
eyes in my life, and Bertrand’s have hurt him several times
lately.”

“I know; so much the better for him,” was the reply. “Well,
good-bye for the present, Ruby. Go on to look for Mavis;
you must face it all—there, the rain is coming now. Ah!”

And with this, which sounded like a long sigh, the voice
seemed to waft itself away, and down came the rain. The
same swirl which had been too much for sturdy Bertrand
was upon Ruby now, standing, too, in a far more exposed
place, with no shelter near, and the rough rocky path before
her. She did not stand long; she turned again and began to
descend, stumbling, slipping, blinded by the rain, dashed
and knocked about by the wind.

“She might have helped me, whoever she was that spoke to
me,” sobbed Ruby. “It isn’t my fault if I can’t see creatures
like that. I’m not good enough, I suppose.”

As she said these last words, or thought them, rather, a


queer little thrill passed through her, and something, in
spite of herself, made her look up. Was it—no, it could not
be—she had suddenly thought a gleam of sunshine and blue
sky had flashed on her sight; but no, the storm was too
furious. “Yet still, I did,” thought Ruby, “I did see something
bright and blue, as if two of my little flowers had got up
there and were looking down on me.”

She glanced at her hand; the forget-me-nots were gone!

“I must have dropped them,” she said. “Oh dear, dear!”

And yet as she struggled on again she did not feel quite so
miserable.

Yet it was terribly hard work, and every moment her anxiety
about Mavis increased; Ruby had never felt so much in all
her life.

“Who could it be that spoke to me so strangely?” she asked


herself over and over again. “And what can I do to be able
to see her? I wonder if Mavis has seen her, I wonder—” and
suddenly there came into her mind the remembrance of
Miss Hortensia’s long-ago story of the vision in the west
turret.
“There was something about forget-me-nots in it,” she
thought dreamily. “Could it have been true?”

How she had mocked at the story!

She had at last reached the shore by this time. The rain still
fell in pitiless torrents, but the wind had fallen a little, and
down here she seemed rather less exposed than on the face
of the cliffs. Still Ruby was completely drenched through;
never before had she had any conception of the misery to
which some of our poor fellow-creatures are exposed to
almost every day of their lives. And yet, her fears for Mavis
overmastered all her other sufferings; for the first time
Ruby thought of another more than of herself.

“Mavis, dear little Mavis, Mavis darling, where are you?” she
sobbed wildly, her teeth chattering, while terrible shivers
shook her from head to foot. “Oh, it can’t be that she is
under those dreadful, fierce, leaping waves. They look as if
they were dancing in cruel joy over something they had
got;” and a shudder worse than those caused by the cold
went through the poor child.

“Mavis,” she called out at last, after she had peered round
about every large stone, every corner where her sister
could possibly have tried to find shelter, without coming
upon the slightest trace of either the child or the boat, “you
must be in the sea. I’ll go after you; it doesn’t matter if I
am drowned if you are. Perhaps—perhaps the mermaids are
keeping you safe; there are kind ones among them it says
in the fairy stories.”

And she turned resolutely to the water. It was cold, icily


cold as it touched first her feet, then her ankles, then crept
up to her knees; it seemed to catch her breath even before
it was at all deep. Ruby felt her powers going and her
senses failing.

“I shall never be able to find Mavis even if she is under the


sea,” she thought to herself, just as a huge wave caught her
in its rolling clutch, and she knew no more.

It seemed as if time beyond counting, years, centuries had


passed when Ruby came to her senses again, enough to
know that she was herself, gradually to remember that
once, long ago, there had been a little girl called Ruby,
somewhere, somehow, and that some one dear, most dear
to her, had been in awful danger from which she had tried
to rescue her. And through all the long mist, through all the
dream wanderings of her spirit, in which may be it had been
learning lessons, the fruit of which remained, though the
teachings themselves were forgotten,—for who knows, who
can limit what we do learn in these mysterious ways?—
Ruby’s guardian angel must have rejoiced to see that the
thought of her sister, not herself, was uppermost.

“Mavis,” was the first word she whispered; “Mavis, are you
alive? Are you not drowned, darling? But it was such a very
long time ago. Perhaps the world is finished. But Mavis—I
thought Mavis was dead; and, oh! who are you?” she ended
with a thrill which seemed to make her quite alive and
awake.

“Are you the fairy in the turret? And what are you doing to
my eyes?”

She sat up and rubbed them. There was the strangest


feeling in them—not pain now; indeed it was, though
strange, a beautiful feeling. They felt drawn upwards,
upwards to something or some one, and a new light and
strength seemed to fill them, light and strength and colour
such as Ruby had never before even imagined. And the
some one—yes, it was the lovely gracious figure, with the
exquisite never-, once seen, to-be-forgotten eyes, of
Winfried’s princess. Ruby saw her at last!

A smile overspread the sweet face; the blue eyes shone


with gladness.

“How often I have hoped for this,” she murmured. “No,


Ruby, you will never know how often. Darling, shut your
eyes, you must not strain them; shut your eyes and think of
Mavis, and trust yourself to me.”

Ruby obeyed; she had not even looked round to see where
she was; she only felt that she was lying on something soft
and warm and dry; oh, how nice it was to feel dry again.
For now the distant, long-ago sensation began to fade, and
she remembered everything clearly as if it had happened,
say, yesterday or the day before at farthest. The naughty
mischief she and Bertrand had been planning, the strange
little boat, the deserted cottage, the hurricane, and the
misery about Mavis, the plunge in search of her into the
sea, even to the loss of the forget-me-nots, which had been
her only comfort, all came back; and with it a wonderful
delightful feeling of hope and peace and trust, such as she
had never known before. She gave herself up to the kind
strong arms that clasped her round! “She will take me to
Mavis,” she thought; “and oh, I will try never, never to be
selfish and unkind and naughty again.”

Then, still wrapped in the soft warm mantle or rug she had
felt herself lying upon, she was lifted upwards, upwards
still, she knew not and cared not whither, for Ruby’s eyes
were closed and she was fast asleep, and this time her
sleep was dreamless.
“Ruby, my own little Ruby,” were the first words she heard.
They awoke her as nothing else would have done.

“Mavis,” she whispered.

Yes, it was Mavis. She was leaning over the couch on which
Ruby lay. Never had Ruby seen her so bright and sweet and
happy-looking.

“Mavis,” Ruby repeated. “And you weren’t drowned, darling?


At least;” and as she raised herself a little she looked round
her doubtfully, “at least, not unless this is heaven? It looks
like it—only,” with a deep sigh, “it can’t be, for if it were, I
shouldn’t be in it.”

“No, darling, it isn’t heaven, but it’s a beautiful place, and I


think it must be a little on the way there. It’s one of the
homes of our princess; she won’t tell me the name, but I
call it Forget-me-not Land. Isn’t that a good name? Look all
about, Ruby.”

They were in a little arbour, in one corner of what one would


have called a garden, except that gardens are usually
enclosed. They don’t stretch as far as the eyes can see,
which was the case here. A soft clear yet not dazzling or
glaring light was over everything, yet there was no sun
visible in the sky. And as Ruby gazed and gazed she began
to feel that there were differences between this garden and
any others she had ever seen. One of these Mavis pointed
out to her.

“Do you see, Ruby,” she said, “that all the flowers in this
garden are our wild flowers, though they are such
beauties?” She stooped to gather one or two blossoms
growing close beside her as she spoke.
“See, here are the same kind of forget-me-nots that were
at the old cottage, and that we found so strangely on the
castle terrace. And here are violets and primroses and
snowdrops, all the spring flowers; and the summer ones
too, honeysuckle and dog-roses; and even the tiny common
ones, buttercups and daisies, and celandine and pimpernel,
and eye-bright and shepherd’s-purse, and—and—”

“But you’re mixing them all up together,” said Ruby. “They


don’t all come at the same time of year.”

“Yes, they do here,” said Mavis. “That’s the wonder. I found


it out for myself almost immediately, and the princess was
so pleased I did. I think this garden is a sort of nursery for
wild flowers; you see up where we live there are no gardens
or gardeners for them.”

“Up!” said Ruby, “are we down below the world? Are we out
of the world?”

Mavis smiled.

“I don’t know,” she said. “It may be up or it may be down.


It doesn’t matter. The princess says we may call it fairyland
if we like. And fancy, Ruby, old Adam is the gardener here.”

A shadow passed over Ruby’s face.

“Don’t be frightened, dear. He knew you were coming, and


he’s as kind as kind. We’re to have supper at his cottage
before we go home.”

“Oh,” said Ruby disappointed, “then we are to go home?”

“Oh yes,” Mavis explained, “it wouldn’t do for us to stay


always here. But I think we may come back again
sometimes. Adam has been often here, ever since he was a
boy, he told me. And now he’s going to stay always, till it’s
time for him to go somewhere else, he says. It was too cold
and rough for him up by the sea now he is so old.”

“And—about Winfried?” asked Ruby, growing very red.

Mavis laughed joyously.

“Winfried,” she cried, “why, he was here already when I


came; the boat went down, down with me, Ruby, when the
great waves rolled over it and me. I was frightened, just for
a minute, and then it was all right, and the princess and
Winfried lifted me out.”

“How many days ago was it?” asked Ruby.

Mavis shook her head.

“I don’t know that either; perhaps it’s not days at all here.
I’ve never thought about it. But cousin Hortensia won’t be
frightened. The princess told me that. Winfried will take us
home. He can’t stay here either; he’s got work to do
somewhere, and he can only come back sometimes. There,
Ruby—look—there he comes; do you see him coming up
that little hill? He’ll be here in a few minutes.”
Chapter Eleven.
Down the Well.

“Blue-bells the news are spreading,


Ring-a-ting, ting, ting, ting!
All the flowers have voices,
Lovely the songs that they sing;
How the blue-bell rejoices,
Ting-a-ring, ting, ting, ting!”

Ruby shrank back a little.

“I don’t want to see Winfried,” she said, “after all we did.


And, oh Mavis, I must be in such a mess—my clothes were
all soaked in the sea.”

“No, they weren’t,” said Mavis, laughing; “at least if they


were they’ve come right again. Stand up, Ruby, and shake
yourself, and look at yourself. There now, did you ever look
neater or nicer in your life?”

Ruby stood up and looked at herself as Mavis advised her.

“Is this my own frock?” she said. “No, it can’t be. See,
Mavis, it’s all beautifully embroidered with forget-me-nots!
And what lovely blue ribbon my hair is tied with; and my
hands are so white and clean Mavis, did the princess dress
me while I was asleep?”

Mavis nodded her head sagely.

“Something like it,” she said.


“And oh,” continued Ruby, “your frock is just the same, and
your ribbons and all. How nice you look, Mavis! Is the
princess here? I should so like her to see us.”

“She’s not here to-day,” said Mavis. “She’s away somewhere


—I’m not sure,” she added in a lower voice, “but that it’s
about Bertrand.”

Ruby gave a sort of shiver.

“Oh Mavis!” she said, “he was so cruel and so heartless, and
I was so miserable. I do hope the princess will make him go
quite away.”

“Or—if he was to be quite changed,” said Mavis.

“No, no. I don’t want him. I only want you, my darling little
Mavis, and we shall be so happy—much, much happier than
we have ever been. Kiss me, Mavis, and tell me you quite
forgive me, and if ever I am naughty or horrid again, I hope
the princess will punish me.”

“She won’t let you forget her any way,” said Mavis. “I think
that is how she punishes.”

Ruby looked rather puzzled; but before she could ask more
they heard Winfried’s whistle, and in a moment he
appeared. His face was all one smile—all Ruby’s fears and
misgivings faded away before it.

“Grandfather is waiting for you,” he said. “There are some


cakes, Miss Ruby, that you will find even better than those
others. For everything is better here, you see.”

“How lovely it must all be,” said Ruby, with a little sigh.
“Aren’t you sorry, Winfried, that you can’t stay here
altogether? Mavis says you have to go away to work.”
“Of course,” said Winfried cheerily. “It would never do,
young as I am, not to work. And we shouldn’t enjoy this
half as much if we had it always—it’s the rest and
refreshment after common life that makes half the
happiness. It’s different for gran—he’s done his part, none
better, and now his work should be light I’m thankful to
know he’s safe here. Now we had better go—down that little
hill is the way to his cottage.”

Children, you have perhaps never been in fairyland, nor, for


that matter, have I been there either. But I have had
glimpses of it a good many times in my life, and so I hope
have you. And these glimpses, do you know, become more
frequent and are less fleeting as one grows older. I, at least,
find it so. Is not that something to look forward to? Though,
after all, this sweet country to which our three little friends,
thanks to the beautiful princess, had found their way, was
scarcely the dream region which we think of as fairyland; it
was better described by little Mavis’s own name for the
nameless garden—“Forget-me-not Land”; for once having
entered there, no one can lose the remembrance of it, any
more than once having looked into her eyes one can forget
Princess Forget-me-not herself.

But it would be difficult to describe this magic land; I must


leave a good deal of it to that kind of fancy which comes
nearer truth than clumsy words. Though, as it is nice to be
told all that can be told of the sweetest and most beautiful
things, I will try to tell you a little of what Ruby and Mavis
saw.

It might not have seemed such a lovely place to everybody,


perhaps. Time had been even when Ruby herself might not
have thought it so; for this garden-land was not a gorgeous
place; it was just sweet and restful. As I told you, all the
flowers were wild flowers; but that gives you no idea of
what they looked like, for they were carefully tended and
arranged, growing in great masses together in a way we
never see, except sometimes in spring when the primroses
almost hide the ground where they grow, or at midsummer
when a rich luxuriance of dog-roses and honeysuckle makes
it seem as if they had been “planted on purpose,” as
children say. All along the grassy paths where Winfried led
them, every step made the little girls exclaim in new
admiration.

“Oh see, Ruby, there is a whole bank of ‘Robin.’ I could not


have believed it would look so beautiful; and there—look at
those masses of ‘sweet Cicely,’ just like snowflakes. And in
our fields it is such a poor frightened little weed of a flower
you scarcely notice it,” said Mavis.

“But it’s lovely if you look into it closely,” said Winfried.


“Some of the very tiniest flowers are really the most
beautiful.”

Then they came in sight of a stretch of hair-bells—white and


blue—the kind that in some places are called “blue-bells.”
“Stop a moment,” said the boy. “Stop and listen—hush—
there now, do you hear them ringing? That is a sound you
can never hear in—anywhere but here.”

They listened with all their ears, you may be sure. Yes, as
they grew accustomed to the exceeding stillness, to the
clear thin fineness of the air, they heard the softest,
sweetest tinkle you can imagine; a perfect fairy bell-ringing,
and the longer they listened the clearer it grew.

“Oh, how wonderful,” said Mavis.

And Ruby added, “I should think if we lived long enough in


this country we should end by hearing the grass growing.”

“Perhaps,” said Winfried.

“But don’t you miss the sea things?” Ruby went on. “You
love them so, Winfried, and somehow you seem to belong
to the sea.”

“So I do,” the boy replied. “The sea is my life. Coming here
is only a rest and a holiday.”

“I wonder,” said Mavis, “I wonder if there is a garden


country for the sea to match this for the land. A place
where seaweeds and corals and all the loveliest sea things
are taken care of, like the wild flowers here?”

“You may be sure there is,” said the fisher-boy, smiling.


“There is no saying what the princess won’t have to show
us, and where she won’t take us now she has us in hand.
Why, only to look into her eyes, you can see it—they seem
to reach to everywhere; everywhere and everything
beautiful seems in them.”

“You have seen farther into them than we have,” said Mavis
thoughtfully. “But still I think I can understand what you
mean.”

“So can I, a very little,” said Ruby. “But—they are rather


frightening too, don’t you think?”
“They must be at first,” said Winfried.

But just then, a little way off, they caught sight of old Adam
coming to meet them. His cottage was close by; they came
upon it suddenly, for it stood half-hidden under the shelter
of the hill they had been descending. Such a lovely cottage
it was—so simple, yet so pretty; quite clean, with a
cleanness you never see out of fairyland or places of that
kind, with flowers of all kinds, forget-me-nots above all,
clustering about it and peeping in at the windows.

Adam welcomed his little guests as kindly as if no unkind


thought of him had ever entered Ruby’s head; he made no
difference between her and Mavis, and I think this caused
Ruby to feel more sorry than anything could have done.

If they had been happy that afternoon in the cottage by the


sea, you can fancy how happy they were in this wonderful
new fairy home of the good old man’s. There was no end to
the things he had to show them and teach them, mostly, I
think, about flowers; things they had never dreamt of,
beauties of form and colour such as it would be impossible
for me to describe. And each time they came to see him he
promised to show and teach them still more. But at last
Winfried said they must be going.

“I promised the princess,” he said, for now he spoke of her


quite openly to the children, “that I would take you home
by the time the sun sets beside the castle, and it must be
near that now.”

“And how are we to go home?” asked Ruby.

“The boat is ready,” Winfried answered.

“But where’s the sea for it to sail on?” whispered Ruby to


Mavis. She had not the courage to ask Winfried anymore.
“Wait and see,” said Mavis. “I don’t know, but it is sure to
be all right.”

Then they bade Adam farewell, promising to come to visit


him again whenever they should be allowed to do so—and
rather wondering where Winfried was going to take them,
they set off.

There was some reason for Ruby’s question, for so far they
had seen no water at all in Forget-me-not Land. Everything
seemed fresh and fragrant, as if there was no dearth of
moisture, but there was neither lake, nor pond, nor running
brook. Winfried mounted the hill a little way, then turning
sharply, they found themselves in a sort of small wooded
ravine or glen. Steps led down the steep sides to the
bottom, which was a perfect thicket of ferns, mostly of the
deep green delicate kind, which loves darkness and water.

Winfried stooped and lifted, by a ring fixed into it, a heavy


stone.

“You won’t be frightened,” he said. “This is the way. We


have to go down the well. I’ll go first; you’ll find it quite
easy.”

It scarcely looked so, for it was very dark. Winfried stepped


in—there was a ladder against the side—and soon
disappeared, all but his head, then Mavis, and lastly,
trembling a little it must be confessed, Ruby. As soon as
they were all inside, the stone lid shut itself down; but
instead, as one might have expected, of this leaving them
in darkness, a clear almost bright light shone upwards as if
a large lamp had been lighted at the foot of the well, and
without difficulty the children made their way down the
ladder.
“That’s very nice,” said Ruby. “I was so afraid we were going
to be in the dark.”

“Were you, dear?” said a voice whose sweet tones were not
strange to her. “No fear of that when I have to do with
things. Jump, that’s right; here you are, and you too,
Mavis.”

The princess was standing in the boat, for the “well”


widened out at one side into a little stream large enough to
row along.

“The brook takes us to the river, and the river to the sea;
that is your way home,” she said. “Winfried will row, and
you two shall nestle up to me.”

She put an arm round each, and in silence, save for the
gentle drip of the oars, the little boat made its way. It was a
still evening, not yet dark, though growing dusk, and
though they were back in the winter world by now the
children felt no cold—who could have felt cold with the
princess’s mantle round them? They grew sleepy, too sleepy
to notice how, as she had said, the brook turned into the
river, and the river led on to the sea, the familiar sea, not
more than a mile or two from the cove below the castle.
And it was only when the boat grated a little on the pebbly
shore that both Ruby and Mavis started up to find
themselves alone with Winfried. The princess had left them.

“I will go up to the door with you,” said the boy. “Miss


Hortensia is expecting you. See, there she is standing under
the archway with a lantern.”

“My darlings,” said their cousin. “So Winfried has brought


you safe home.”
“And I must hurry back,” said the fisher-lad. And almost
before they could thank him or say good-night, he had
disappeared again in the fast-gathering gloom.

It seemed to the children as Miss Hortensia kissed them


that years had passed since they had seen her or their
home.

“Haven’t you been dreadfully lonely without us all this time,


dear cousin?” said Mavis.

“No, dears, not particularly so. It is a little later than usual,


but when Winfried ran back to tell me he would bring you
safe home, he said it might be so.”

“Was it only this afternoon we went?” said Ruby


wonderingly.

Miss Hortensia looked at her anxiously.

“My dear, are you very tired? You seem half asleep.”

“I am rather sleepy,” said Ruby. “Please may we go to bed


at once.”

“Certainly. I will tell Ulrica to take your supper upstairs. I do


hope you haven’t caught cold. We must shut the door;” for
they were standing all this time at the entrance under the
archway. “Bertrand is behind you, I suppose?”

The little girls looked at each other.

“We have not seen him for ever so long,” they replied.

“He would not stay with me,” said Ruby.

“I thought perhaps we should find him here,” said Mavis.


Miss Hortensia looked more annoyed than anxious. “I
suppose he will find his way back before long,” she said.
“Bad pennies always turn up. But he is a most troublesome
boy. I wish I had asked Winfried what to do—”

“I don’t think he could have done anything,” said Mavis.


“But—I’m sure Bertrand is safe. What’s the matter, Ulrica?”

For at that moment—they were on their way upstairs by this


time—the young maid-servant came flying to meet them,
her face pale, her eyes gleaming with fear.

“Oh,” she cried, “I am glad the young ladies are safe back.
Martin has seen the blue light in the west turret; he was
coming from the village a few minutes ago, and something
made him look up. It is many and many a year since it has
been seen, not since the young ladies were babies, and it
always—”

“Stop, Ulrica,” said Miss Hortensia sharply. “It is very wrong


of you to come startling us in that wild way, and the young
ladies so tired as you see. Call Bertha and Joseph. You take
the children to their room, and see that they are warm and
comfortable. I will myself go up to the west turret with the
others and put a stop to these idle tales.”

But Ruby and Mavis pressed forward. A strange thought had


struck them both.

“Oh cousin, let us go too,” they said. “We are not a bit
frightened.”

So when old Joseph and Bertha had joined them, the whole
party set off for the turret.

As they got near to the top of the stair, a slight sound made
them all start.
“Hush!” said Miss Hortensia. They stood in perfect silence. It
came again—a murmur of faint sobs and weeping. Ulrica
grew whiter and whiter.

“I told you so,” she began, but no one listened. They all
pressed on, Miss Hortensia the first.

When she opened the door it was, except for the lamp she
held in her hand, upon total darkness. But in one corner
was heard a sort of convulsive breathing, and then a voice.

“Who’s there? Who’s there? Oh the pain, the cruel pain!”

And there—lying on the same little couch-bed on which


years and years ago Miss Hortensia had slept and dreamt of
the lovely fairy lady—was Bertrand—weeping and moaning,
utterly broken down.

But he turned away sullenly from Miss Hortensia when she


leant over him in concern and pity; he would not look at
Ruby either, and it was not till after some moments had
passed that they at last heard him whisper.

“Mavis, I want to speak to Mavis. Go away everybody. I only


want Mavis.”

They all looked at each other in mute astonishment. They


thought he was wandering in his mind. But no; he kept to
the same idea.

“Mavis,” he repeated, “come here and give me your hand. I


can’t see you. Oh the pain, the pain!” Then Mavis came
forward, and the others drew back in a group to the door.

“Try and find out what it is; surely it is not another naughty
trick that he is playing,” said Miss Hortensia anxiously.
“No, no. I am sure it isn’t. Don’t be afraid, dear cousin,”
said the little girl.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like