pydemo | Get Productive with Python and Visual Studio Code | Code Editor library
kandi X-RAY | pydemo Summary
kandi X-RAY | pydemo Summary
This repo contains code and links for the "Get Productive with Python and Visual Studio Code" talk. If you want to give the talk yourself, run the setup.py setup script (using python3) to check out and initialize code repos & snippets, and run the reset.py script that resets the code back to the start of the demo (useful when practicing!). These scripts will only work on macOS and Windows.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Run Python interpreter
- Run a shell command
pydemo Key Features
pydemo Examples and Code Snippets
Community Discussions
Trending Discussions on pydemo
QUESTION
I want to read a file, 4 lines by 4 (it's a fastq file, with DNA sequences).
When I read the file one line by one or two by two, there's no issues, but when I read 3 or 4 lines at once, my code crashes (kernel appeared to have died on jupyter notebook). (Uncommenting the last part, or any 3 out of the 4 getline()
.
I tried with a double array of char (char**) to store the lines, with the same issue.
Any idea what can be the cause ?
Using Python 3.7.3, Cython 0.29, all other libraries updated. File being read is about 1.3GB, machine has 8GB, ubuntu 16.04. Code adapted from https://gist.github.com/pydemo/0b85bd5d1c017f6873422e02aeb9618a
...ANSWER
Answered 2021-Apr-26 at 11:27The underlying problem was my misunderstanding of getline()
getline() c reference
To store lines in different variables, an associated n
is necessary for each line pointer *lineptr
.
If *lineptr is set to NULL and *n is set 0 before the call, then getline() will allocate a buffer for storing the line.
Alternatively, before calling getline(), *lineptr can contain a pointer to a malloc(3)-allocated buffer *n bytes in size. If the buffer is not large enough to hold the line, getline() resizes it with realloc(3), updating *lineptr and *n as necessary.
The n
(or seed
in my code) will hold the size of the buffer allocated for the pointer, where getline() puts the incoming line. As I set the same buffer variable for different pointers, getline was given the wrong information of the size of the char* line_xxx.
As fastq files are usually in this shape:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pydemo
You can use pydemo like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page