Skip to content

Instantly share code, notes, and snippets.

View sdshlanta's full-sized avatar

Mike Shlanta sdshlanta

  • Los Alamos National Lab
  • Los Alamos, NM
View GitHub Profile

Comments on optimizations around string concatenation.

Note: The code links are to CPython 3.8.5, the most recent release when this was written.

I was recently asked about a performance optimization in CPython around using += and + for string objects. As some people may already know, if you use += or + a string, it can sometimes be just as fast as ''.join. The question was to explain when that optimization couldn't be performed.

We will be going through the following example scenarios:

@ewauq
ewauq / logitech-bind-f13-f24.lua
Last active October 9, 2024 21:26
How to: Bind F13 to F24 keys on the G-keys (Logitech Gaming Keyboards)
-- How to use this script:
-- 1. Install the Logitech Gaming Software: http://support.logitech.com/en_us/software/lgs
-- 2. Launch it, and right click on your profile (the gear icon) and then click on "Scripts".
-- 3. Add the following code into the Script window, save it, and close it. Enjoy.
-- Now G1 is bound to F13, G2 to G14, ... G12 to F24.
function OnEvent(event, arg)
-- OutputLogMessage("event = %s, arg = %s\n", event, arg)
// ==UserScript==
// @name vmware open console in new tab
// @namespace http://agartner.com
// @version 0.2
// @description opens vmrc console in new tab rather than window. also forces html5 console if html5 = true. forces external if externalConsle = true
// @match https://vcloud.ialab.us/cloud/org/*
// @copyright 2014-2017, Alex Gartner
// ==/UserScript==
unsafeWindow.openPopoutConsole = function(vmName, vmId, vAppName, vmDevicesAvailable, buttonLabels, miscLabels, confirmationLabels, isVmrc) {
@ivanleoncz
ivanleoncz / flask_app_logging.py
Last active May 23, 2021 07:25
Demonstration of logging feature for a Flask App.
#/usr/bin/python3
""" Demonstration of logging feature for a Flask App. """
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
__author__ = "@ivanleoncz"
import logging