Share on facebook
Share on twitter
Share on linkedin
Share on email

Migrating Tag Inspector from Python 2 to Python 3

Python 2 to Python 3

Recently, our engineering team completed a migration of our proprietary tag auditing and management platform from Python 2 to Python 3. This upgrade brings with it a host of positive changes to Tag Inspector that will seek to improve performance and reduce bugs. Most notably, switching to Python 3 will future-proof our application’s security and stability.

Earlier this year, the Python Software Foundation announced that Python 2 will reach end-of-life on Jan. 1, 2020. This simply means that moving forward, Python 2 will no longer receive updates from its developers.

Porting Challenges

Porting from Python 2 to Python 3 is no easy task. This is what, historically, has kept Python 2 alive. Python is well known for its vast array of third-party libraries; these libraries must also then be ported into the new codebase. This usually presents one of two challenges.

On one hand, if the team behind the library hasn’t upgraded it to Python 3, the burden of that task falls onto the shoulders of our developers. On the other hand, teams who do port to Python 3 will often take the opportunity to update their framework in such a way as to break existing code that implements their library. Existing programs must be rewritten to fit the new library’s language. Even a single added character in a function name can—and will—grind an application to a halt. Our engineers were able to tackle and overcome both of these challenges.

Unicode Enhancements

Python 3 also brings with it code-wide Unicode enhancements. What this means is that text in Python 3 is now stored as Unicode rather than ASCII, the old default. As a web scraping application, Tag Inspector will encounter a lot of non-English Unicode characters that cannot be encoded to ASCII. Normally, trying to encode these characters into the proper character set would often throw errors since you won’t always know what character set your application is reading—a fact that is particularly true for web applications. 

This is quite possibly the best new feature for our purposes, yet it did come with its own challenges. Like I mentioned before, a change of this magnitude requires an extensive rewrite of much of the code. While Python 3 introduces text as Unicode, it also supports a different datatype (simply called bytes, or bytestring). This datatype is comprised of fully encoded text—the actual bits that make up the string. Python 2 was more-or-less the opposite: normal strings were encoded and Unicode had its own special string datatype. As you can guess, this presented an issue with the migration.

How can you easily tell which datatype any given string is in the old codebase? Luckily, Python 3 ships with a fantastic debugging tool: the -b command line option. Passing this flag when running your script lets you know exactly where you are trying to compare strings to bytes. This makes it simple to hunt down which line in your script is expecting a different datatype than it is being given. The -b flag gives developers an obvious leg up when navigating the new string datatypes.

Set Up for Success

In the end, although migrating to Python 3 is no easy task, our engineering team was able to successfully complete the project and deliver a wonderful and exciting new implementation. This is the same Tag Inspector that you are used to but faster, less buggy, and ready for anything the future may bring.

Now Hiring Software Engineers

Interested in working on our Tag Inspector proprietary software?
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on email
Email

Other Articles You Will Enjoy

InfoTrust Becomes Official Google Cloud Partner

InfoTrust Becomes Official Google Cloud Partner

For years, the experienced cloud engineering team at InfoTrust has helped major multi-brand clients across the globe drive their business objectives forward. With a…

Deloitte Recognizes InfoTrust in Annual Technology Fast 500 Ranking

Deloitte Recognizes InfoTrust in Annual Technology Fast 500 Ranking

Last week, Deloitte honored the experienced digital analytics consulting, data governance, and technology team at InfoTrust among the 500 fast-growing North American companies in…

The Most Useful Google Analytics Reports and Dashboards for Black Friday

The Most Useful Google Analytics Reports and Dashboards for Black Friday

With the holiday season rapidly approaching, Black Friday weekend is just around the corner. Recently, we asked if your digital analytics team is ready…

Migrating Tag Inspector from Python 2 to Python 3

Migrating Tag Inspector from Python 2 to Python 3

Recently, our engineering team completed a migration of our proprietary tag auditing and management platform from Python 2 to Python 3. This upgrade brings…

Get to Know All the Products in the Google Marketing Platform

Get to Know All the Products in the Google Marketing Platform

While most organizations are aware of the Google marketing stack, many only utilize one or two of its products. While using a single Google…

In-Housing in Your Organization’s Future? Start with This Conversation

In-Housing in Your Organization’s Future? Start with This Conversation

It’s time to have a real conversation about your company’s internal structure and capabilities. Are you being asked by management to make in-housing a…

Tag Inspector’s Cookie Detection Feature Receives Quanties Award for Best New Technology

Tag Inspector’s Cookie Detection Feature Receives Quanties Award for Best New Technology

At the Digital Analytics Association’s OneConference event last evening in Chicago, Tag Inspector’s new cookie detection feature received the Quanties Award for Best New…

Lead Analytics Consultant Mai AlOwaish Honored with DAA President’s Award

Lead Analytics Consultant Mai AlOwaish Honored with DAA President’s Award

At InfoTrust, our team works not only to grow our business and community, but also to further the digital analytics industry as a whole….

Join InfoTrust on the Journey Towards Organizational Maturity in Supporting Equality in Tech

Join InfoTrust on the Journey Towards Organizational Maturity in Supporting Equality in Tech

One of the pivotal moments of my career as an entrepreneur was hearing Jeff Hoffman share his legacy as a founder of Priceline.com, uBid.com,…

Our website uses cookies and may collect user information to provide a good experience. Read our Privacy Policy here.

Leave Us A Review

Leave a review and let us know how we’re doing. Only actual clients, please.