Advanced Python Programming – Second Edition (E-book)

159,00 

Description

Pythons powerful capabilities for implementing robust and efficient programs make it one of the most sought-after programming languages.In this book, youll explore the tools that allow you to improve performance and take your Python programs to the next level.This book starts by examining the built-in as well as external libraries that streamline tasks in the development cycle, such as benchmarking, profiling, and optimizing. Youll then get to grips with using specialized tools such as dedicated libraries and compilers to increase your performance at number-crunching tasks, including training machine learning models.The book covers concurrency, a major solution to making programs more efficient and scalable, and various concurrent programming techniques such as multithreading, multiprocessing, and asynchronous programming.Youll also understand the common problems that cause undesirable behavior in concurrent programs.Finally, youll work with a wide range of design patterns, including creational, structural, and behavioral patterns that enable you to tackle complex design and architecture challenges, making your programs more robust and maintainable.By the end of the book, youll be exposed to a wide range of advanced functionalities in Python and be equipped with the practical knowledge needed to apply them to your use cases. Spis treści:Advanced Python ProgrammingSecond EditionContributorsAbout the authorAbout the reviewersPrefaceWho this book is forWhat this book coversTo get the most out of this bookDownload the example code filesDownload the color imagesConventions usedGet in touchShare Your ThoughtsSection 1: Python-Native and Specialized OptimizationChapter 1: Benchmarking and ProfilingTechnical requirementsDesigning your applicationBuilding a particle simulatorVisualizing the simulationWriting tests and benchmarksTiming your benchmarkWriting better tests and benchmarks with pytest-benchmarkFinding bottlenecks with cProfileGraphically analyzing profiling resultsProfiling line by line with line_profilerOptimizing our codeUsing the dis moduleProfiling memory usage with memory_profilerSummaryQuestionsFurther readingChapter 2: Pure Python OptimizationsTechnical requirementsUsing the right algorithms and data structuresLists and dequesDictionariesHash mapSetsHeapsTriesImproved efficiency with caching and memoizationJoblibEfficient iteration with comprehensions and generatorsSummaryQuestionsFurther readingChapter 3: Fast Array Operations with NumPy, Pandas, and XarrayTechnical requirementGetting started with NumPyCreating arraysAccessing arraysIndexing and slicingFancy indexingBroadcastingMathematical operationsCalculating the normRewriting the particle simulator in NumPyReaching optimal performance with numexprWorking with database-style data with pandaspandas fundamentalsIndexing Series and DataFrame objectsDatabase-style operations with pandasMappingGrouping, aggregations, and transformsJoiningHigh-performance labeled data with xarrayAnalyzing concentrationThe xarray libraryImproved performancePlotting with xarraySummaryQuestionsFurther readingChapter 4: C Performance with CythonTechnical requirementsCompiling Cython extensionsAdding static typesDeclaring variablesDeclaring functionsDeclaring classesSharing declarationsWorking with arraysC arrays and pointersWorking with NumPy arraysWorking with typed memoryviewsUsing a particle simulator in CythonProfiling CythonUsing Cython with JupyterSummaryQuestionsChapter 5: Exploring CompilersTechnical requirementsGetting started with NumbaUsing Numba decoratorsType specializationsObject mode versus native modeNumba and NumPyUniversal functions with NumbaGeneralized universal functionsJIT classesLimitations in NumbaThe PyPy projectSetting up PyPyRunning a particle simulator in PyPyOther interesting projectsSummaryQuestionsFurther readingChapter 6: Automatic Differentiation and Accelerated Linear Algebra for Machine LearningA crash course in machine learningModel parametersLoss functionLoss minimizationGetting JAX up and runningInstalling JAXUsing Google ColabAutomatic differentiation for loss minimizationMaking the datasetBuilding a linear modelGradient descent with automatic differentiationJust-In-Time compilation for improved efficiencyAutomatic vectorization for efficient kernelsData that is not linearly separableThe kernel method in machine learningAutomatic vectorization for kernelized modelsSummaryQuestionsFurther readingSection 2: Concurrency and ParallelismChapter 7: Implementing ConcurrencyTechnical requirementsAsynchronous programmingWaiting for input/outputConcurrencyCallbacksFuturesEvent loopsThe asyncio frameworkCoroutinesConverting blocking code into non-blocking codeReactive programmingObservablesUseful operatorsHot and cold observablesBuilding a CPU monitorSummaryQuestionsFurther readingChapter 8: Parallel ProcessingTechnical requirementsIntroduction to parallel programmingGPUsUsing multiple processesThe Process and Pool classesThe Executor interfaceMonte Carlo approximation of piSynchronization and locksParallel Cython with OpenMPAutomatic parallelismGetting started with TheanoProfiling TheanoTensorFlowRunning code on a GPUSummaryQuestionsChapter 9: Concurrent Web RequestsThe basics of web requestsHTMLHTTP requestsHTTP status codeThe requests moduleMaking a request in PythonRunning a ping testConcurrent web requestsSpawning multiple threadsRefactoring request logicThe problem with timeoutsSupport from httpstat.us and simulation in PythonTimeout specificationsGood practices in making web requestsConsider the terms of service and data-collecting policiesError handlingUpdate your program regularlyAvoid making a large number of requestsSummaryQuestionsFurther readingChapter 10: Concurrent Image ProcessingTechnical requirementsImage processing fundamentalsPython as an image processing toolInstalling OpenCV and NumPyComputer image basicsRGB valuesPixels and image filesCoordinates inside an imageOpenCV APIImage processing techniquesGrayscalingThresholdingApplying concurrency to image processingGood concurrent image processing practicesChoosing the correct way (out of many)Spawning an appropriate number of processesProcessing input/output concurrentlySummaryQuestionsFurther readingChapter 11: Building Communication Channels with asyncioTechnical requirementsThe ecosystem of communication channelsCommunication protocol layersAsynchronous programming for communication channelsTransports and protocols in asyncioThe big picture of asyncios server clientGetting started with Python and TelnetStarting a serverInstalling TelnetSimulating a connection channelSending messages back to clientsClosing transportsClient-side communication with aiohttpInstalling aiohttp and aiofilesFetching a websites HTML codeWriting files asynchronouslySummaryQuestionsFurther readingChapter 12: DeadlocksTechnical requirementsThe concept of deadlocksThe dining philosophers problemA deadlock in a concurrent systemPython simulationApproaches to deadlock situationsImplementing ranking among resourcesIgnoring locks and sharing resourcesAn additional note about locksConcluding note on deadlock solutionsThe concept of livelocksSummaryQuestionsFurther readingChapter 13: StarvationTechnical requirementsUnderstanding starvationWhat is starvation?SchedulingCauses of starvationStarvations relationship to deadlockApproaching the readers-writers problemProblem statementThe first readers-writers problemThe second readers-writers problemThe third readers-writers problemSolutions to starvationSummaryQuestionsFurther readingChapter 14: Race ConditionsTechnical requirementsThe concept of race conditionsCritical sectionsHow race conditions occurSimulating race conditions in PythonLocks as a solution to race conditionsThe effectiveness of locksImplementation in PythonThe downside of locksTurning a concurrent program into a sequential programLocks do not lock anythingRace conditions in real lifeSecurityOperating systemsNetworkingSummaryQuestionsFurther readingChapter 15: The Global Interpreter LockTechnical requirementsIntroducing the GILAnalyzing memory management in PythonThe problem that the GIL addressesProblems raised by the GILThe potential removal of the GIL from PythonWorking with the GILImplementing multiprocessing, rather than multithreadingGetting around the GIL with native extensionsUtilizing a different Python interpreterSummaryQuestionsFurther readingSection 3: Design Patterns in PythonChapter 16: The Factory PatternTechnical requirementsUnderstanding design patternsImplementing the factory methodReal-world examplesUse casesImplementing the factory methodApplying the abstract factoryReal-world examplesUse casesImplementing the abstract factory patternSummaryQuestionsChapter 17: The Builder PatternTechnical requirementsUnderstanding the builder patternReal-world examplesUse casesImplementing an ordering applicationSummaryQuestionsChapter 18: Other Creational PatternsTechnical requirementsImplementing the prototype patternReal-world examplesUse casesImplementationImplementing the singleton patternReal-world examplesUse casesImplementationSummaryQuestionsFurther readingChapter 19: The Adapter PatternTechnical requirementsUnderstanding the adapter patternReal-world examplesUse casesImplementationSummaryChapter 20: The Decorator PatternTechnical requirementsIntroducing the decorator patternReal-world examplesUse casesImplementationSummaryQuestionsChapter 21: The Bridge PatternTechnical requirementsReal-world examplesUse casesImplementationSummaryQuestionsChapter 22: The Façade PatternTechnical requirementsUnderstanding the façade patternReal-world examplesUse casesImplementationSummaryQuestionsFurther readingChapter 23: Other Structural PatternsTechnical requirementsImplementing the flyweight patternReal-world examplesUse casesImplementationImplementing the model-view-controller patternReal-world examplesUse casesImplementationApplying the proxy patternReal-world examplesUse casesImplementationSummaryQuestionsChapter 24: The Chain of Responsibility PatternTechnical requirementsUnderstanding the Chain of Responsibility patternReal-world examplesUse casesImplementationSummaryQuestionsChapter 25: The Command PatternTechnical requirementsUnderstanding the command patternReal-world examplesUse casesImplementationSummaryQuestionsChapter 26: The Observer PatternTechnical requirementsUnderstanding the observer patternReal-world examplesUse casesImplementationSummaryQuestionsAssessmentsChapter 1Chapter 2Chapter 3Chapter 4Chapter 5Chapter 6Chapter 7Chapter 8Chapter 9Chapter 10Chapter 11Chapter 12Chapter 13Chapter 14Chapter 15Chapter 16Chapter 17Chapter 18Chapter 20Chapter 21Chapter 22Chapter 23Chapter 24Chapter 25Chapter 26Why subscribe?Other Books You May EnjoyPackt is searching for authors like youShare Your Thoughts

miłość hiszpańska, morawska joanna, przydatne darmowe aplikacje, przydatne słówka na mature z angielskiego, pozycjonowanie stron gliwice, przedszkole 83 gdańsk, matura język angielski 2017, księgarnia językowa sosnowiec, ciasna, zbiór zadań z fizyki liceum, google translate angielski, szybko po włosku, tematy egzaminu osmoklasisty 2022, metody aktywizujące na lekcji wychowania fizycznego

yyyyy