What is the Python Global Interpreter Lock (GIL)?

Pavitra
Updated on 28-Aug-2019 13:52:08

403 Views

In this article, we will learn about What is the Python Global Interpreter Lock (GIL).This is a lock or hindrance that resistant the availability of the Python interpreter to multiple threads simultaneously. GIL is identified as a fault/issue in Python 3.x. Or earlier as it doesn’t allow multithreading in a multi-threaded architecture.Why is it introduced?Python supports the concept of automatic garbage collection. As soon as the reference count of an object reaches zero the memory is cleaned and free for usage.>>> import sys >>> var = {} >>> print(sys.getrefcount(ar)) >>> 2 >>> v=var >>> print(sys.getrefcount(v)) >>> 3Of in this case ... Read More

Vectorization in Python

Pavitra
Updated on 28-Aug-2019 13:47:51

1K+ Views

In this article, we will learn about vectorization and various techniques involved in implementation using Python 3.x. Or earlier.What is Vectorization?Vectorization is a technique to implement arrays without the use of loops. Using a function instead can help in minimizing the running time and execution time of code efficiently. Various operations are being performed over vector instead of arrays such as dot product of vectors which is also known as scalar product as it produces single output, outer products which results in square matrix of dimension equal to (length X length) of the vectors, Element wise multiplication which products the ... Read More

Is Printable in Python and Its Application

Pavitra
Updated on 28-Aug-2019 13:21:48

258 Views

In this article, we will learn about isprintable() in Python and its application.Is printable() is a built-in method used for the purpose of string handling. The isprintable() methods return “True” when all characters present in the string are of type printable or the string is empty, Otherwise, It returns a boolean value of “False”.Arguments − It doesn’t take any argument when calledList of printable characters include digits, letter, special symbols & spaces.Let’s look at this illustration to check that whether the characters of string are printable or not.Example Live Demo# checking for printable characters st= 'Tutorialspoint' print(st.isprintable()) # checking if ... Read More

Introduction to Machine Learning Using Python

Pavitra
Updated on 28-Aug-2019 13:14:12

377 Views

In this article, we will learn about the basics of machine learning using Python 3.x. Or earlier.First, we need to use existing libraries to set up a machine learning environment>>> pip install numpy >>> pip install scipy >>> pip install matplotlib >>> pip install scikit-learnMachine learning deals with the study of experiences and facts and prediction is given on the bases of intents provided. The larger the database the better the machine learning model is.The flow of Machine LearningCleaning the dataFeeding the datasetTraining the modelTesting the datasetImplementing the modelNow let’s identify which library is used for what purpose −Numpy − adds ... Read More

Code Splitting in React JS

Shyam Hande
Updated on 28-Aug-2019 09:16:34

312 Views

We bundle the files in React application using tool such as webpack. Bundling in the end merges the files in the sequence of their imports and creates a single file.The problem with this approach is that the bundle file gets larger with the increase in files. User may not be sung all the feature components but still bundle is loading them, this could affect the loading of application.To avoid this, code splitting is used in React.ExampleExample of bundling −// app.js import { total } from './math.js'; console.log(total(10, 20)); // 42 // math.js export function total(a, b) {    return a ... Read More

Accessibility in React JS

Shyam Hande
Updated on 28-Aug-2019 09:12:18

450 Views

The aria-* attributes on html elements are also supported in React.js as well. The other attributes are generally written in camel-case but these aria-* are written in hyphen-cased.Sometimes we break the semantics of the html if we use parent div in React.jsExamplerender(){    return(                Test          ); }Div can cause semantics issue if working with table, list etc. To avoid this we can use React provided fragment as shown below −import React, { Fragment } from ‘react’; function MessageList({ message }) {    return (       ... Read More

Thinking in React JS

Shyam Hande
Updated on 28-Aug-2019 09:07:45

689 Views

React community has provided a direction on how to think in React way and build big , fast and scalable applications. React has reached multiple platforms and widely used a popular JavaScript UI interface library.Step 1 − Creating a simple mock serviceIf we need to make a server call and fetch data. We can create a mock service to start with and build a component to fetch and display data.Here we can include the processing of json in component and evaluating the expected result.Step 2 − Break the functionality into smaller componentsThe first Thing React suggest is to create the ... Read More

Composition vs Inheritance in React JS

Shyam Hande
Updated on 28-Aug-2019 09:03:12

3K+ Views

Composition and inheritance are the approaches to use multiple components together in React.js . This helps in code reuse. React recommend using composition instead of inheritance as much as possible and inheritance should be used in very specific cases only.Example to understand it −Let’s say we have a component to input username.Inheritanceclass UserNameForm extends React.Component {    render() {       return (                                       );    } } ReactDOM.render(    < UserNameForm />,    document.getElementById('root'));This sis simple to just input ... Read More

Lifting State Up in React JS

Shyam Hande
Updated on 28-Aug-2019 08:56:40

751 Views

Often there will be a need to share state between different components. The common approach to share state between two components is to move the state to common parent of the two components. This approach is called as lifting state up in React.jsWith the shared state, changes in state reflect in relevant components simultaneously. This is a single source of truth for shared state components.ExampleWe have a App component containing PlayerContent and PlayerDetails component. PlayerContent shows the player name buttons. PlayerDetails shows the details of the in one line.The app component contains the state for both the component. The selected ... Read More

Uncontrolled Component in ReactJS

Shyam Hande
Updated on 28-Aug-2019 08:52:15

461 Views

In controlled component form data is handled by React component by writing event handler for state updates. But in uncontrolled component, form data is handled by DOM itself.ref is used to receive the form value from DOM.Exampleclass UserNameForm extends React.Component {    constructor(props) {       super(props);       this.handleFormSubmit = this.handleFormSubmit.bind(this);       this.inputUserName = React.createRef();    }    handleFormSubmit(event) {       console.log('username: ' + this.inputUserName.current.value);       event.preventDefault();    }    render() {       return (                           ... Read More

Advertisements