Thursday, May 16, 2024
HomePythonreader 3.0 launched - demise and gravity

reader 3.0 launched – demise and gravity


Hello there!

I am completely satisfied to announce model 3.0 of reader, a Python feed reader library.

This launch removes quite a lot of deprecated strategies and attributes,
for a cleaner, extra constant API.
See the changelog for particulars.

2.x recap

2.0 was launched over a yr in the past;
let’s have have a look at what occurred since.

Unified tag API + entry and international tags

Tags and metadata at the moment are the identical factor, generic useful resource tags:

>>> reader.get_tag(feed, 'one', 'default')
'default'
>>> reader.set_tag(feed, 'one', 'worth')
>>> reader.get_tag(feed, 'one')
'worth'
>>> reader.set_tag(feed, 'two')
>>> dict(reader.get_tags(feed))
{'one': 'worth', 'two': None}

This implies you’ll be able to filter by metadata keys, and fix values to tags.

Even higher, tags aren’t only for feeds anymore –
you’ll be able to add tags to entries, and to a worldwide namespace.

Search enabled by default

Full-text search works out of the field:
no additional dependencies, no setup wanted.

Statistics

There at the moment are statistics on feed and consumer exercise,
to provide you a greater understanding of the way you devour content material.

First, you will get the common variety of entries per day
for the final 1, 3, 12 months,
so you understand how typically a feed publishes new entries,
and the way that modified over time –
assume sparklines: 36 entries ▄▃▁ (4.0, 2.0, 0.6).

Second, reader data the time when an entry
was final marked as learn or vital.
This may assist you to see the way you interact with new entries
– I am nonetheless engaged on easy methods to translate this information right into a helpful abstract.

A pleasant side-effect of understanding when entry flags modified
is that it is potential to inform
if an entry was explicitly marked as unimportant
(entries are unimportant by default).

Consumer-added entries

Now you can add entries to current feeds.
That is helpful while you wish to preserve observe of an article
that’s not within the feed anymore as a result of it “fell off the tip”.

It will also be used to construct bookmarking / learn later performance
much like that of Tiny Tiny RSS;
extracting content material from arbitrary pages can be fairly useful right here.

Twitter help

Now you can observe Twitter accounts
(experimental, requires a Twitter account).

Learn time

The brand new readtime plugin calculates the entry learn time throughout feed updates.

This makes accessible to any reader consumer
a function that was solely accessible within the net app,
and makes the net app sooner.

Improved duplicate dealing with

Duplicate dealing with received considerably higher:

  • False negatives are decreased by utilizing approximate string matching
    and heuristics to detect truncated content material.
  • You’ll be able to set off entry deduplication manually,
    for the prevailing entries of a feed
    – simply add the .reader.dedupe.as soon as tag to the feed,
    and anticipate the following replace.
    Additionally, you’ll be able to deduplicate entries by title alone, ignoring content material.
  • Previous duplicates are deleted as an alternative of marked as learn/unimportant.

Reminiscence utilization enhancements

reader replace makes use of about 22% much less reminiscence.

The primary change is to not reader itself,
however was contributed upstream to feedparser:
as an alternative of studying the entire feed in reminiscence to detect encoding,
use a prefix of the feed, and decode the remainder on the fly.
The result’s a 35% lower in update_feeds() most RSS
when in comparison with baseline!

Yow will discover extra particulars right here.

Multithreading

Now you can use the identical Reader object from a number of threads.
So, you are able to do stuff like this:

>>> Thread(goal=reader.update_feeds).begin()

Additionally, you’ll be able to reuse Reader objects after closing.

Typing

reader has had sort annotations for many of its existence;
beginning with 2.14, consumer code can use them too.

New Python variations


Over the course of two.x,
reader received help for Python 3.10, and PyPy 3.8 and three.9,
and dropped help for Python 3.7.

Different adjustments

Except for the adjustments talked about above,
a number of comfort strategies, arguments, and attributes have been added.
Among the many extra notable ones, now you’ll be able to:

  • filter feeds in the identical manner each when getting and when updating feeds
    – together with by tags
  • run arbitrary actions earlier than and after updating feeds

That is it for now.

Discovered one thing new immediately? Share this with others, it actually helps!

What’s reader?

reader takes care
of the core performance required by a feed reader,
so you’ll be able to give attention to what makes yours totally different.

reader permits you to:

  • retrieve, retailer, and handle Atom, RSS, and JSON feeds
    • and even observe Twitter accounts
  • mark articles as learn or vital
  • add arbitrary tags/metadata to feeds and articles
  • filter feeds and articles
  • full-text search articles
  • get statistics on feed and consumer exercise
  • write plugins to increase its performance

…all these with:

  • a secure, clearly documented API
  • glorious take a look at protection
  • absolutely typed Python

To seek out out extra, take a look at the GitHub repo and the docs,
or give the tutorial a strive.

Why use a feed reader library?

Have you ever been sad with current feed readers and wished to make your personal, however:

  • by no means knew the place to start out?
  • it appeared like an excessive amount of work?
  • you do not like writing backend code?

Are you already working with feedparser, however:

  • need a better strategy to retailer, filter, kind and search feeds and entries?
  • wish to get again type-annotated objects as an alternative of dicts?
  • wish to limit or deny file-system entry?
  • wish to change the best way feeds are retrieved by utilizing Requests?
  • wish to additionally help JSON Feed?
  • wish to observe Twitter accounts?
  • wish to help customized data sources?

… whereas nonetheless supporting all of the feed sorts feedparser does?

If you happen to answered sure to any of the above, reader might help.

Why make your personal feed reader?

So you’ll be able to:

  • have full management over your information
  • management what options it has or does not have
  • determine how a lot you pay for it
  • make sure that it does not get closed whilst you’re nonetheless utilizing it
  • actually, it is simpler than you assume

Clearly, this will not be your cup of tea, however whether it is, reader might help.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments